Backport r3780.