Cleanup and isolate code to allow loading YAML into OrderedDict