Refactor persistence