Fixed many NullReferenceExceptions