Fix null pointer dereference

Closes #316