backported fix for #562 to master
Merge pull request #570 from nelenkov/master

backported fix for #562 to master