refs #3 refactored debug handling