Backport fix for #163 into 0.11.0

As reported by @espes the fix for #163 is only in the master branch, but it applies for 0.11.0 as well.