Fix for issue 92 and code tidy