Fixes for memory management of g-boxed-refs