cleaned up some code and comments