Made library threadsafe.