Fix errorstream vs input strean and use THREAD_POOL_EXECUTOR