Cleanup

Mostly adding whitespace for readability.

Also fixed some comments and removed unused code.