Fixes a problem in one of the previous commits

It also needs to assign the element if the key already exists.
CAIWorker and CAIPlayer heap rooting changes