Cleaned up code leading to the solver