remove for...of blocks (#1554)

It turns out that current transpilers do a terrible job with `for...of` blocks - see #1554. (My initial assumption was that `let` was to blame - I was mistaken.) This PR replaces most of the occurrences with `forEach`, and the other one with `while`.