Fixed destructors to stop Segfault on exit