- Refined retry delay logic for clarity and correctness in `getNextRetryDelay`. - Added `connectRef` to ensure latest `connect` function is called in retries. - Separated cleanup and connection management effects to prevent premature disconnections. - Enhanced inline comments for maintainability.