Cleaned up discovery loop code in client_base