Fixes to threading model