Tidy up debug logging