Tidy up comments, obsolete code and minor changes