fixes #665
manual merge of #1526