fixed some concurrency issues.