Cleaning up some bugs