cleaned up some code, added some comments
cleaned up code, added some comments