Refactoring PersistenceManager and ContextHelper classes