Optimize threadpool.
Remove unused code.