Tidy up of code and comments