Issue #1322: Ported 3f34b61 into the 3.0 branch