Fix connection bugs