Fix cases where connection was not being closed
Also fix improper retain on delegate