Debug output.
Added assertion to prevent core dump.
Fixed merge conflict (both fixing the same core dump caused by NULL ptr).