Refactor dbaccess into separate module