Fix for #3498.
Merge pull request #3620 from Segrain/master

Bugfix.