Added proper cleanup of all resources in _rt_delete.