A better fix for #2110 while preserving the fix for #1634.