Backport to 3.3.1 branch Fix/3.3.1/issue 3704

Fixes #3704