Fix some NULL pointer dereferences, most of the in debug code though.