set log level and tidy up