Code cleanup - move old iterator/while loops to for loops