Slightly more abstracted

Abstracted low-level calculations and interactions with savegame files
away from scripts.