Tidy up code and comments for submission.