Fixed up some bugs