Re-write to use Scheduler instead of threads.