Fixed 'loop' code generation bug in tasks.