Misc cleanup and commenting

Let me know what you think.