Fix IDs and sort