Fix a few minor bugs