Integrate remaining parts of #14247 [from HEAD].