refactor: extract out the transactioning part of _main().
groups: saving the persistent data.
wip