Fix reconnection bug, and IO bug.