Other solution would be to check and disallow any game changing method while this event is being invoked, but it would require a lot of extra ifs in the Factorio internals and the solution doesn't seem to be clean enough to me.
So the changes would be:
- on_load/on_save completely removed
- on_init would be called not only when the game is started but also when the mod was added to an existing game and the game.
- new event on_mod_configuration_changed would be called whenever the game was loaded and some of the existing mods is missing, some mod was removed or version of some was mod changed.
- There could also be added event something like my_version_changed. It would be called whenever version of the mod was changed (the user upgraded your mod, and you might need to migrate some structures), the event could even contain the previous version of your mod as parameter.