Fix thread-safety compatibility