Refactoring how debug works