Cleaned up disconnect logic, tidied logging and handlers.