Error handling for memory allocations
Add destructors