Add destructors, fix memory leaks