Here’s a little something about Safe Pointers:
Safe Pointers provide a reference counting facility to deal with
access types without compromizing safety, i.e. safe pointers clean up
behind themselves properly; no dangling references can ever be
On the website there are plenty of usage examples to be found and a very thorough explanation of the package.