Factored out threads and queues