Fix cleaning up the module storage for circular dependencies