added a few comments cleaned up some code