Adjust and simplify the codes in "thread_download".