add debug module, refactoring all debug messages