Added proper deallocation