Improve check-all-merges script