Fix for #6476.
Fix for #6643.
Fix for #7322.
Merge pull request #7339 from Segrain/master

Bugfixes.