Tidy up of debug code