Add a DEBUG_LOG macro for logging when DEBUG is enabled and replace #ifdef DEBUG/fprintf(...)/#endif blocks
Move macro definitions to a new header file