I don't like that we're introducing `factory_deleted` where `cfg_m->driver_factory` being NULL should be the same thing.  If we could get a pointer to `cfg_m` here we could reuse the `if (cfg_m->driver_factory != NULL) { delete cfg_m->driver_factory; cfg_m->driver_factory = NULL; }` code from before.  I'm ok with this as is if it's too awkward to get a `cfg_m`, though.