Merge pull request #396 from aguibert/backport-pr-395

Backport recent bug fixes to 1.0.X