refactoring some debug staff