   restoreState: (state) =>
     @is_on = state.status.dynamic_mode ? false
     @random_ids = state.status.random_ids ? {}
+    @history_size = state.status.dynamic_history ? 10
+    @future_size = state.status.dynamic_future ? 10
 
   saveState: (state) =>
     state.status.dynamic_mode = @is_on
     state.status.dynamic_mode_enabled = @is_enabled
     state.status.random_ids = @random_ids
+    state.status.dynamic_history = @history_size
+    state.status.dynamic_future = @future_size
 
   setConf: (conf, conf_path) =>
     @is_enabled = true


    if @is_on
      commands = []
      delete_count = Math.max(current_index - 10, 0)
      for i in [0...delete_count]
        commands.push "deleteid #{item_list[i].id}"
      add_count = Math.max(11 - (item_list.length - current_index), 0)

      commands = commands.concat ("addid #{JSON.stringify file}" for file in @getRandomSongFiles add_count)
      @mpd.sendCommands commands, (msg) =>


  onSocketConnection: (socket) =>
    socket.on 'DynamicMode', (data) =>
      return unless @is_enabled
      value = JSON.parse data.toString()
      return if @is_on == value
      @log.debug "DynamicMode is being turned #{value}"
      @is_on = value
      @checkDynamicMode()
      @onStatusChanged()

  checkDynamicMode: =>
    return unless @is_enabled
    return unless @mpd.library.artists.length
