Adding some comments and cleaning up some code