Debug refactor to add debug level, and cleanup of debug across the project