Ensure ordered dictionaries remain ordered.

Our dictionary helper functions caused ordered dictionaries to be
replaced with ordinary dictionaries. Ensure that the output dictionary
type matches the input and ordering will be preserved due to in-order
iteration.
Small clean up for dictionary helpers.