Improve thread-safety