Refactored the persistence layer