Simplification of part of the fix in #871