Added comments. Misc clean up.

Added comments for readability. Cleaned up unused code.