backport fix for #1013 to 1.4-branch