Backport of fix #31 from 1.6 branch