Convert to and from orddicts

Otherwise we get incorrect merges (duplicates).
merge heads