Refactoring and debugging