Implement destructors to clean allocated memory.