Correct backport of PR #4928