Backported #370 fix to 1.0 branch