add final comments and tidy up