fix mismatched free()/delete's