changes to fix UI bugs with state transitions
implemented a graceful disconnect andcleaned up the UI
clean up of disconnect method
changes based on pr comments
cleaned up js code based on code review