Big dumb refactor

This is the refactor part of the persistence work that i was working on.