thread safe fixes