Move thread-specific debug code out of debug\main.c