Added more robust plug/unplug reconnect behavior.