Fix threading

First benchmarks show this new implementation is a bit more than twice
as slow though.