Use ranges instead of lists in for loops for perf reasons.