some more work on thread safety