Fix up some bugs