Adding comments, and cleaning up code.