Some tidy up and use of logging