Use C++11 range-based loops in a few places