Fix reconnect after server disconnect

Fixes #1679
Fixes #1568
Fixes #1659