Fixing loop generation.