Added thread pool support

And some cosmetics