Fix a couple of annoying bugs