Fix for issue #241 plus tidying