refactor the constraint solver and de-emberize the solver for perf reasons