Added comments to code and did code cleanup