Added robustness to loops (II).