Improve solver.cpp