Monothreaded version works.
Merged code.