Added check for DEBUG shell variable so it doesn't crash if DEBUG is not defined.