Backport PR #4027 to 1.8

Backport gh-4027 to 1.8