Refactor several iterator-loops to foreach-loops
temp