Added robustness to loops (I).