Managing allergenic/gluten cross-contamination is a top priority for food processors. In highly automated facilities, the control system can assist with product scheduling to mitigate these risks, coupled with robust monitoring and enforcement to help prevent circumstances where such risks tend to lurk.
Complicating any scheduling process is the requirement of sequencing certain product types in specific orders. For example, if you are making vanilla pudding, it is often permissible to follow that product run with chocolate pudding. Reverse the production order, and residual traces of chocolate color could ruin your vanilla product. Of larger concern is the potential carry-over of allergenic/gluten ingredients from one product into another under similar circumstances.