Improved thread safety.