GenBCode: cleanup optimizations

Method-level cleanup optimizations.

See individual commit messages.
Hmm, but it requires a `toList`, so probably not much faster in the end.. `Collections.foreachWithIndex(list.asScala.toList) { case (l, i) =>`