Corrected destructors taking into account the ownership of the data