Split make-connection implementation in various functions.