Patched over the output ordering problem using a temporary ordered dictionary.