Minor docs and code cleanup

**To all contributors, please document the code as much as possible. It's very hard to read through the code when many people work, use different naming conventions and philosophies. Please add comments to almost anything you write.**