Re-order some of the new connect code.

Signed-off-by: Moritz Ulrich <moritz@tarn-vedra.de>