Refacted batch allocator.