Code to manage persistence layer