savegame: moving variables into helper functions