Beginning of thread pool implementation