Fix for NullReferenceException