Improve debug code functionality
Change some function to use the new debug library