Refactor debugging