Wrote destructor and clear functions