fixed connection bugs. need to fix reconnect bug.