Some reordering and merging