Fixed connect on startup and disconnect/reconnect code