Added comments to all major functions and classes. Fixed various formatting and code verbosity.