Destructor functions working for reference pointers.