Tidy up debug code and comments