lib.connections: improve connect()