Adding several protections against null pointers.
Closes #53