Tidy up debugger function