fixes #5796
Merge pull request #6887 from Glloyd/fixes

Fixes #5796