Fixes concurrent access race condition.
Fixes out of index error.