tidy up, comments and startup error handling