Fix a few code issues