Merge pull request #3790 from Segrain/master

Bugfixes.