Use optimised forEach in more places, and clarify variable names