The generated loops had 1 too many iterations. This has now been fixed.