Optimize controller and model