Merge pull request #389 from cpoulain/master

Merge substantive changes from PR #386.