More commenting and TODOs

I think I'm all caught up on commenting now. I still need to simplify a
lot of big ugly functions with helper functions and returns instead of
nesting. Most of the bad ones are labeled with TODOs.