fix debug handling
only include debug functions if needed
Merge pull request #238 from mehlis/debug-guard

Debug: guard some code