Debugging: move debug function definitions in misc.cpp