# Buggy code
def __init__(self, index, sort=False, processed=False):
    self.index = index
    if not processed:
        for fkey, info in iteritems(index.copy()):
            if fkey.endswith("]"):
                continue
            for fstr in chain(
                info.get("features", "").split(),
                info.get("track_features", "").split(),
                track_features or (),
            ):
                self.add_feature(fstr, group=False)
            for fstr in iterkeys(info.get("with_features_depends", {})):
                index["%s[%s]" % (fkey, fstr)] = info
                self.add_feature(fstr, group=False)

    groups = {}
    trackers = {}
    installed = set()
    for fkey, info in iteritems(index):
        groups.setdefault(info["name"], []).append(fkey)
        for feat in info.get("track_features", "").split():
            trackers.setdefault(feat, []).append(fkey)
        if "link" in info:
            installed.add(fkey)

    self.groups = groups
    self.installed = installed
    self.trackers = trackers
    self.find_matches_ = {}
    self.ms_depends_ = {}

    if sort:
        for name, group in iteritems(groups):
            groups[name] = sorted(group, key=self.version_key, reverse=True)


# Traceback (TypeError)
Traceback (most recent call last):
File "/home/ilan/minonda/bin/conda", line 6, in <module>
sys.exit(main())
File "/home/ilan/conda/conda/cli/main.py", line 120, in main
args_func(args, p)
File "/home/ilan/conda/conda/cli/main.py", line 127, in args_func
args.func(args, p)
File "/home/ilan/conda/conda/cli/main_install.py", line 62, in execute
install.install(args, parser, 'install')
File "/home/ilan/conda/conda/cli/install.py", line 394, in install
plan.execute_actions(actions, index, verbose=not args.quiet)
File "/home/ilan/conda/conda/plan.py", line 555, in execute_actions
inst.execute_instructions(plan, index, verbose)
File "/home/ilan/conda/conda/instructions.py", line 133, in execute_instructions
cmd(state, arg)
File "/home/ilan/conda/conda/instructions.py", line 80, in UNLINK_CMD
install.unlink(state['prefix'], arg)
File "/home/ilan/conda/conda/install.py", line 1075, in unlink
mk_menus(prefix, meta['files'], remove=True)
TypeError: 'NoneType' object has no attribute '__getitem__'

# Fixed code
def __init__(self, index, sort=False, processed=False):
    self.index = index
    if not processed:
        for fkey, info in iteritems(index.copy()):
            if fkey.endswith("]"):
                continue
            for fstr in chain(
                info.get("features", "").split(),
                info.get("track_features", "").split(),
                track_features or (),
            ):
                self.add_feature(fstr, group=False)
            for fstr in iterkeys(info.get("with_features_depends", {})):
                index["%s[%s]" % (fkey, fstr)] = info
                self.add_feature(fstr, group=False)

    groups = {}
    trackers = {}
    installed = set()
    for fkey, info in iteritems(index):
        groups.setdefault(info["name"], []).append(fkey)
        for feat in info.get("track_features", "").split():
            trackers.setdefault(feat, []).append(fkey)
        if "link" in info and not fkey.endswith("]"):
            installed.add(fkey)

    self.groups = groups
    self.installed = installed
    self.trackers = trackers
    self.find_matches_ = {}
    self.ms_depends_ = {}

    if sort:
        for name, group in iteritems(groups):
            groups[name] = sorted(group, key=self.version_key, reverse=True)