Fix the errors from trying to dereference nulls.