Backport commit r4607