fixup some bugs