Small refactoring, added debugging tool