refactor persistence and serialization