       throw "obj already exists"
     list.splice pos, 0, obj
 
-  doNothing = ->
+  noop = ->
 
   escape = (str) ->
     # replace all " with \"
-    str.replace /"/g, '\\"'
+    str.toString().replace /"/g, '\\"'
 
   createEventHandlers: =>
     registrarNames = [

        handlers.splice i, 1
        return

  sendCommand: (command, callback) =>
    @msgHandlerQueue.push callback
    @send command

  sendCommands: (command_list, callback) =>
    return if command_list.length == 0
    @msgHandlerQueue.push callback
    @send "command_list_begin\n#{command_list.join("\n")}\ncommand_list_end"



  queueFile: (file) =>
    @sendCommand "add \"#{escape(file)}\""

  play: => @sendCommand "play"
  pause: => @sendCommand "pause"
  next: => @sendCommand "next"
  prev: => @sendCommand "previous"

  playId: (track_id) =>
    @sendCommand "playid #{escape(track_id)}"

