It would help to use OrderedDict correctly.