patches to use unique_ptr instead of counted_ptr