Item instantiation vs. item creation

This will lead to serious issues, unless you can guarantee that
the two functions can never be called parallely for the same refmodel
instance.

I would move the ram_item declaration inside the functions.