fix several bugs.

and reduce the threads