Refactored batch allocator.