Incorporate the fix for issue 1181 without breaking 2217.