backport ed8153ca03b9, addresses #1467