Improvement to the solver heuristics

This should fix #415