Simple NPE check. Fixes #315