Clean up code by adopting C++11 idioms for loops.