GenBCode: cleanup optimizations

Method-level cleanup optimizations.

See individual commit messages.
Hmm, there's no global or symbol table in scope, so I can't get to `foreachWithIndex`..