Fix possible NullReferenceException.