cleaned up some bugs
cleaned up code