Clean up the logic in fragment merging

14 jobs for r22 in 10 minutes and 38 seconds (queued for 1 second)