Change the NULL checks to assertions. This is a programmer bug.