#3873

Moved the fixes from #3837  to master-2.5.

Please check.