Big dumb refactor

This is the refactor part of the persistence work that i was working on.
Rather than revert I think we start from this and edit it to the new simpler rules.