Refactor massive draw function.

Move chunks of logic to well-named functions, so I can see what's going
on in the draw loop.