Expand on the refcounting

Memory management in XS is tricky. Try to expand on it some.