Update to the persistence code

ready for testing/debugging. mostly debugging I’m sure.