tidied up debug stuff