Thread pool refactoring