Fix segfaults while accessing null-pointers