Improve thread safety.