Deallocation errors fixed