Harden NPE check

Signed-off-by: Chris Sanders <zidane@outlook.com>