Fix sleep error and add debug info.