Fixes #973.

Adds a NPE guard.