Bugfix: fixed a bug that caused ugly artifacts to appear sometimes while
computing constraints. The fix also improved the constraints computation
speed at least several times :)