Added state switching on connect.