Complete the fix for #4980 started in 31b2574194d5333c65aec34c916609bad4b9490d