Fixed some connection bugs