Persistence layer ported from MARV project.