added complete implementation of DEBUG_MODE