Refactored expiration and timeout logic in client_core.rb