Refactoring a little: introduce the taskpool module.