Rework of 1ad9 as per pull request #237.