made code for pipe handling more modular
Added threadpool class