Backport fix in r1301 to branch 1.0.