Got state save to work in run_optimization.