Refactor debugging tools