Debug Refactor

Refactored Debug class to for better error/exception handling.