added test sorting with duplicate generated mappings
Handle null 'mapping.original'.
Remove debug code.