Add in some NPE evasion. Fixes #42.