Fix null dereference of pointers

Fixes issue #76