Fix a few null pointer exceptions