Cleaned up code and output, added comments