Rendering code cleanup part 1: eliminating reuse of loop variables and naming unnamed variables.
Rendering code cleanup round 2: eliminating more variable reuse, and naming more vars.