       clearSlots: () ->
         schemeMsg chalk.yellow "clearing all slots"
         scheme.slots = {}
+        scheme.next = 0
         saveDataFile()
         programDone()
 

  return () ->
    # make these variables available outside of initialize scope
    dataDir = data = dataFile = currentScheme = scheme = commands = colors =
      history = undefined

    schemeMsg = (msg) ->
      console.error chalk.cyan("[ #{currentScheme} ]") + " - #{msg}"

    saveDataFile = () ->
      fs.writeFileSync(dataFile, JSON.stringify(data), "utf8")

    initalizeScheme = (scheme) ->
        data.schemes[scheme] =
          slots: {}
        saveDataFile()


        console.log _path
        programDone()

      removeSlot: (idx) ->
        idx = parseInt(idx)
        fatalError "argument <idx> should be a whole number" unless _.isNumber(idx) and not _.isNaN(idx) and idx >= 0
        delete scheme.slots[idx]
        doAutoCompact() if autoCompact
        saveDataFile()
        programDone()

      switchSlots: (idx1, idx2) ->
        idx1 = parseInt(idx1)
        fatalError "argument <idx1> should be a whole number" unless _.isNumber(idx1) and not _.isNaN(idx1) and idx1 >= 0
        idx2 = parseInt(idx2)
        fatalError "argument <idx2> should be a whole number" unless _.isNumber(idx2) and not _.isNaN(idx2) and idx2 >= 0
        fatalError "argument <idx1> is not valid" unless _.isString(scheme.slots[idx1])
        fatalError "argument <idx2> is not valid" unless _.isString(scheme.slots[idx2])
        temp = scheme.slots[idx1]
        scheme.slots[idx1] = scheme.slots[idx2]
        scheme.slots[idx2] = temp
        saveDataFile()
        programDone()

      saveSlot: (idx, _path) ->
        if idx? and idx.match /^[0-9]+$/
          idx = parseInt(idx)
          fatalError "argument <idx> should be a whole number" unless _.isNumber(idx) and not _.isNaN(idx) and idx >= 0
        else
          # if idx is a string but not digits, assume it is the path
          _path = idx if _.isString(idx)
          idx = scheme.next

        _path = process.cwd() unless _.isString(_path)
        fatalError "path #{_path} does not exist" unless fs.existsSync _path
        scheme.slots[idx] = _path
        doAutoCompact() if autoCompact and idx > scheme.next
        scheme.next = parseInt(_.max(_.keys(scheme.slots))) + 1
        schemeMsg "saving slot #{chalk.yellow idx} as #{chalk.grey _path}"
        saveDataFile()
        programDone()
