Fix 'missing function dbg' error

functions were defined in a conditional block after use.  Move the function definitions out of the if ... block to fix