backport PR #3885