Fixed possible threading issue.
Fixed possible threading issues.