fix some concurrency edge cases.