Move DictionaryFlattener into a middleware