Fixes #1573: check for null