Refactor database adapters