Hacked in some ugly and inflexible reconnect logic.