Check for null to avoid issue #848