Fix a few crashes