Lots of bugfixes, typos and cleanup

(the only times forEach is needed afaik is when there are multiple types in the array, or you use a _forEachIndex)