manual merge of #637

manual merge of Amebel's pull request #637