Switch to range-based for where possible.
Remove dead code from range-for change.