back port the other crucial changes so we don't free(NULL)