Refactored unit of work handling