Refactored to use a threadpool for building