Wip on refactoring db for atomic transactions.