Moved all connection-related block from _new_conn() to a helper function