Refactor some for-iterator loops to range-for to improve readability.

Authored by johanneszarl on Apr 7 2019, 9:29 PM.