Persistent store

I think this is ready but mostly a long winded diff