refactor of core persistence layer