Generate simpler loops

This pull request prevents the compiler from generating lots and lots of `frame.set` calls for variables that never get used.