Made parts of run_optimization faster.

Especially removed the very slow save function.
Turns out that it's really slow when saving function handles...