Fix #70 and detect connection type