on_unload bugfix