Backport of PR #836 from master to 2.x branch.

Signed-off-by: Michael Genereux <mgenereu@gmail.com>
Merge pull request #961 from mgenereu/2.x

Backport of PR #836 from master to 2.x branch.