STY: Change variable names and use viewitems

viewitems is a py2/py3 compatible version of items for dictionaries.
Additionally some of the variable names were changed to be more
descriptive about the data they contain.