Backport pr #81 into 0.9.x

Fixes #35.