Code cleanup

Cleaned up the code a little bit, and added more comments.  Also
whatever changes were made during the 2nd competition.