fix up some bugs