Range-ify some for loops.