Further simplify from r253832 with some unique_ptr and coalescing conditions