fixed some bugs in multithreading