Fix connection deallocation