Cleaned up pointers in class destructors to prevent memory leaks.