fix crash from Conn use after free and double-free

fixes #159