Lots of bugfixes, typos and cleanup

Hmm did not do that on purpose. Are we spelling `foreach` or `forEach`? I'm thinking we should go for `forEach` cause that is what the wiki dictates.

I'll do a lookup for all forEach loops and change them to counts (where possible).