Fixed some bugs with ThreadPool