Backport of pr #710 to 0.9.x branch
Backport of pr #710 to 0.9.x branch