Database access refactor.