Add back code that was previously added in 79f02fe5 and dd03017e but later copy-reverted so it was no longer there.