Painfully fix threadsafety issue