Fix pointer use; add destructor to free memory