Thread safety Fixes.