Minor changes in the code without functional change and a bit of formatting. Part of pr #332 from github Contributed by Graham Russell