Fixed bug in autoreconnecting