allocator: split into two phases