Leftover rewrite code.
Pull Yang's latest changes, including threadpool fix.