Fix for #3406.
Fix for #3383. Again.
Fix for #3410.
Merge pull request #3409 from Segrain/master

Bugfixes.