Fixed several null pointers