Fix issue #2681 (alternative to PR #2690)