use OrderedDict instead of list of tuples. other cleaning