 
     brewing.dibs.push(dibber)
 
-    threadedMsg(msg).send "Ok @#{dibber}, you grabbed :coffee: ##{brewing.dibs.length}! #{statusEmoji.random('success')}"
+    threadedMsg(msg).send "Ok @#{dibber}, you grabbed :coffee: ##{brewing.dibs.length}! " +
+        "#{statusEmoji.random('success')}"
 
   isBrewing = ->
     return brewing.dibs?
 
   threadedMsg = (msg) ->
-    # Ensure that the vote response sticks to the original thread
-    metadata = msg.envelope.metadata || {}
-    metadata.room = brewing.messageMetadata.room if brewing.messageMetadata.room
-    metadata.thread_id = brewing.messageMetadata.thread_id if brewing.messageMetadata.thread_id
-    metadata.message_id = brewing.messageMetadata.message_id if brewing.messageMetadata.message_id
-    msg.envelope.metadata = metadata
+# Ensure that the vote response sticks to the original thread if using the flowdock adapter
+    if robot.adatperName = 'flowdock'
+      metadata = msg.envelope.metadata || {}
+      metadata.room = brewing.messageMetadata.room if brewing.messageMetadata.room
+      metadata.thread_id = brewing.messageMetadata.thread_id if brewing.messageMetadata.thread_id
+      metadata.message_id = brewing.messageMetadata.message_id if brewing.messageMetadata.message_id
+      msg.envelope.metadata = metadata
     msg
 
   handleNoBrew = (msg) ->

    brewing =
      barista: barista
      dibs: [barista],
      messageMetadata: msg.envelope.message.metadata,

    robot.brain.save()

    msg.send "@team Brew started by @#{brewing.barista}! #{statusEmoji.random('success')}\n" +
      "To grab a spot use: #{robot.alias}dibs\n" +
      "To end the brew use: #{robot.alias}fresh pot"

  endBrew = (msg) ->

    teamNotify = brewing.dibs.length < dibsLimit

    expiry = new Date (new Date()).getTime() + dibsDuration*1000

    claims = []
    for i in [1..dibsLimit]
      dibber = brewing.dibs[i-1]

      if dibber
        client = robot.brain.userForName dibber

        if dibber == brewing.barista
          coffeeconomy.deposit client, dibsLimit-1
        else
          coffeeconomy.withdraw client, 1

        account = coffeeconomy.account client

        claims.push("**@#{dibber}** " +
          "#{if dibber == brewing.barista then '_(barista)_ :chart_with_upwards_trend:' else ':chart_with_downwards_trend:'} " +
          "#{coffeeconomy.balanceFormatter account.balance}")
      else
        claims.push "_Unclaimed!_"

    threadMsg = threadedMsg(msg)
    threadMsg.send "#{if teamNotify then '@team: ' else ''}Fresh Pot!!! #{msg.random freshPots} " +
      ":coffee: Claims (valid until #{dateformat expiry, 'h:MM:ss tt'}):\n" +
      ("#{(parseInt index)+1}. #{claim}" for index, claim of claims).join("\n")

    if claims.length > 1
      setTimeout ->
        threadMsg.send "Claims have expired!"
      , dibsDuration*1000

    brewing = {}
    robot.brain.save()

    @brain.save()

  orderedAccounts: (descending = true, limit = false) ->
    accounts = ( {
      accountNumber: accountNumber,
      balance: account.balance
    } for accountNumber, account of @storage )

    first = if descending then 1 else 0
    second = if descending then 0 else 1
    accounts.sort -> arguments[first].balance - arguments[second].balance
    accounts[...(limit || accounts.length())]

  top: (limit = 10) ->
    @orderedAccounts true, limit
