threadsafe improvements