Initial cleanup.

Lots of nitpicky things. Very little logic changes.