Redo PR #1780 to fix issue #1779