Backport fix from trunk.