Fixed up some bugs, added some error checking
changed some variables, added some methods
Fixed up a typo