Rewrite core threading, part 1