make module-unloading behavior flexible