fix a few annoying bugs