Rewritten version of the constraint solving.