First simpler refactorings.
Refactorings 2.
Refactoring 3.
Refactoring 4.
Seems the non-monotone line search is not working atm.
Refactoring 5. Old tests fail...
Switch to FirstOrderMinimizer worked, but test seem to be slower.
After more hacking line search seems to work again.
Replace ThreadLocals by variables.
Synchronize cache update in Cached(Batch)DiffFunction.
Factor out trait Projecting.
Project gradient so we abort iteration correctly.
Add forgotten file.
Use improvement compared to last n runs as stopping criterion.
Rename optTol to tolerance in PQN for unified names.
Move some things around in SPG.
Move line search to an extra class.
Pull out a method for stopping iteration in FirstOrderMinimizer.