Finishing the implementation of haaroptimizer2.cpp. Factored some extra
code into optimization_commons.h. haaroptimizer.cpp is now also using
the trainingtools library.