Fix NameErrors when unloading some modules

Fix crash
Fix crash