Issue #1366

This PR reverts a fix for #1321 which caused #1366.
Then there is change which will hopefully fix #1321.