Added logic to ensure UI state correctly updates on F5
changes to fix UI bugs with state transitions
implemented a graceful disconnect andcleaned up the UI