Optimizing Flows and Resources in a Flexible Production System