TODO: swap threads for tasks.

(not done, just marked as todo)