Replaced for loops by while loops on constraint solver inner loop.