Adding all the code from refactoring of HstoreFlattenFields.