Added comments, formatted code, final revisions.