Backport fix for #38 and #39 from 1.3
Merge branch '1.2'