Fix a few small bugs