Branch for fixing 3602706
cherry-pick [0f098031c3]
re-apply [8aca9a8e96], while backporting [d91c86d0da] from trunk.
This fixes bugs #3601260 and #3602706