       numwant = 50 if isNaN(numwant) or numwant < 0 or numwant > 50
       
       multi
-        .ZCOUNT(key + ':seeds', 0, t)
-        .ZCOUNT(key + ':peers', 0, t)
+        .ZCARD(key + ':seeds')
+        .ZCARD(key + ':peers')
         .ZRANGE(key + ':seeds', 0, numwant)
         .ZRANGE(key + ':peers', 0, numwant)
         .exec (err, replies) =>
+          #res.end 'hi'
+          #return
           if err? then return simple_response res, {'failure reason': 'wat'}
           doCompact = get_vars['compact'] is '1'
           
           peerlist = replies[5].concat(replies[6])
             .slice(0, numwant)
             .map (p) ->
-              [peer_id, ip, port, compacted] = JSON.parse p
-              if doCompact then compacted else {'peer id': peer_id, ip, port}
-          peerlist = peerlist.join '' if doCompact
+              if doCompact
+                return p.slice 20, 26
+              else
+                return {'peer id': p.slice(0, 20), 'ip' : p.slice(26,41) , 'port' : p.slice(41,46)}
+          if doCompact
+            out = new Buffer (peerlist.length*6)
+            for i in [0..peerlist.length-1]
+              peerlist[i].copy out, i*6, 0
+            peerlist = out
           
           return simple_response res,
             'interval'     : ANNOUNCE_INTERVAL

# helper functions
simple_response = (res, data) ->
  res.setHeader 'Content-Type', 'text/plain'
  res.end bencode data

compact = (ip, port) -> ip.split('.').concat([port >> 8 & 0xFF, port & 0xFF]).map((c) -> String.fromCharCode c).join('')

parse = (qs) ->
  obj = {}

    obj[kvp.substr(0, x)] = kvp.substr(x + 1) if ~(x = kvp.indexOf '=')
  obj

#bencode.bencode = (o) -> new Buffer 1
#bencode = (o) ->
#  bstring = (s) -> s.length + ':' + s
#  bint = (n) -> "i#{n}e"
#  blist = (l) ->
#    buf = 'l'
#    buf += bencode i for i in l
#    buf + 'e'
#  bdict = (d) ->
#    buf = 'd'
#    buf += bstring(k) + bencode(d[k]) for k in Object.keys(d).sort()
#    buf + 'e'
#  
#  switch typeof o
#    when 'string' then bstring o
#    when 'number' then bint    o
#    when 'object'
#      if o instanceof Array
#        blist o
#      else if o?
#        bdict o
#      else
#        throw new Error('cannot encode element null')
#    else
#      throw new Error('cannot encode element ' + o)

decodeURLtoHex = (str) ->
  output = ''
  for i in [0..str.length-1]
    if (str.charCodeAt i)== 37
      output += str[i+1] + str[i+2]
      i += 2
    else
      output += (str.charCodeAt i).toString 16
  return output.toLowerCase()

decodeURLtoBinary = (str, len) ->
  b = new Buffer len
  j = 0
  for i in [0..str.length-1]
    if (str.charCodeAt i)== 37
      b[j] = parseInt(str[i+1] + str[i+2], 16)
      i+=2
    else
      b[j] = str.charCodeAt i
    j += 1
  return b

# Tracker class
class Tracker
  constructor: (port) ->
    # redis
    @redis = require('redis').createClient 6379, '127.0.0.1', {'return_buffers' : true}
    @redis.on 'ready', -> console.log 'connected to redis'
    
    # mongodb
