insert_missing() and fix_marks() to correct missing and repeated marks