General tidy up of comments and code