Simplify a lot of iterator loops by using C++11 for-each