Final commit for the day. Cleaned up the code formatting and extending the in code documentation so people understand exactly what part of the code does what.