Merge "fix race condition that can cause a use after free" into oc-dev