backport fix for #985 to 1.4-branch