Model refactoring. Dividing into persistence and api layers