Add NPE check

Fixes #1090
Fix Soaryn's broken stuff
More stuff for Soaryn