Fix for issue #840