Cleaned up and optimised Solver class