Add test.
Lots of debugging...
Merge branch 'master' into qpm
Fix race condition