Fix a few NULL pointer dereferences.