 
       clearInterval intervalId
 
-      # Check the old kites vs the new kites
+      # Find a new kite, from the kite list.
+      # NOTE: This only handles the first kite. This is mostly because
+      # we need a point at which we stop "heartbeating". If multiple
+      # new kites are needed in the future, we probably want to add
+      # a parameter for the number of kites to "heartbeat" for.
       newKite = null
       for kite in kites
-        if oldKites[kite.keyId]
+        unless kite.machine
           newKite = kite
           break
 

# a new kite.
MAX_HEARTBEATS = 60
# The default heartbeat interval, in seconds.
HEARTBEAT_INTERVAL = 5


# Not exported

    queryPromise.catch (err) ->
      kallback err  if err

  # The delay serves to give klient time to connect, reducing unneeded
  # heartbeats.
  heartbeatDelay = HEARTBEAT_DELAY - interval
  heartbeatDelay = 0  if heartbeatDelay < 0

  setTimeout (->
      intervalId = setInterval heartbeat, interval * 1000
  ), heartbeatDelay * 1000
  return


