Added loop support
Fixes to loop support