refactor to have swappable persistence, and dynamically loaded