Squash. Database access refactoring