Fixed connection lifecycle issue