backport of fix for #8