The changes in this function look good.

That said, parts of this function are pretty tricky, and future maintainers would benefit for better explanation of the tricker parts of the code ( eg. '1 << oc->id ).  I don't want to hold up this pull, so maybe add a TODO: for adding some additional comments?