Few misc. changes, primarily avoiding a KeyError which cropped up due to
another silly mistake.