Refactor transaction scope API and implementations