Refactoring for ease of changine main solver.