debug: refactored exception handling, moved debugging to a single file