             } catch {
                 throw StaffError.noNextNoteToTie
             }
-            secondMeasure = try mutableMeasureFromNotesHolderIndex(secondNotesHolderIndex.notesHolderIndex, repeatMeasureIndex: secondNotesHolderIndex.repeatMeasureIndex)
-            guard let noteCount = secondMeasure?.noteCount, noteCount > 0 else {
+            var secondMeasure = try mutableMeasureFromNotesHolderIndex(
+				secondNotesHolderIndex.notesHolderIndex,
+				repeatMeasureIndex: secondNotesHolderIndex.repeatMeasureIndex)
+            guard secondMeasure.noteCount > 0 else {
                 throw StaffError.noNextNoteToTie
             }
+
+			if !removeTie {
+				let firstNoteIndex = try firstMeasure.noteCollectionIndexFromNoteIndex(noteIndex)
+				var firstNote: Note
+				if firstNoteIndex.tupletIndex == nil {
+					firstNote = firstMeasure.notes[firstNoteIndex.noteIndex] as! Note
+				} else {
+					guard let tuplet = firstMeasure.notes[firstNoteIndex.noteIndex] as? Tuplet,
+						let tupletIndex = firstNoteIndex.tupletIndex else {
+							assertionFailure("Index translation showed should be a tuplet, but it's not")
+							throw StaffError.internalError
+					}
+					firstNote = tuplet.notes[tupletIndex]
+				}
+				
+				let secondNoteIndex = try secondMeasure.noteCollectionIndexFromNoteIndex(0)
+				var secondNote: Note
+				if secondNoteIndex.tupletIndex == nil {
+					secondNote = secondMeasure.notes[secondNoteIndex.noteIndex] as! Note
+				} else {
+					guard let tuplet = secondMeasure.notes[secondNoteIndex.noteIndex] as? Tuplet,
+						let tupletIndex = secondNoteIndex.tupletIndex else {
+							assertionFailure("Index translation showed should be a tuplet, but it's not")
+							throw StaffError.internalError
+					}
+					secondNote = tuplet.notes[tupletIndex]
+				}
+				
+				if firstNote != secondNote {
+					throw StaffError.noSameNoteTie
+				}
+			}
+			
+			// Modify tie and update second Measure. The first Measure update is done later.
+			try firstMeasure.modifyTie(at: noteIndex, requestedTieState: removeTie ? nil : .begin )
+			try secondMeasure.modifyTie(at: 0, requestedTieState: removeTie ? nil : .end)
+			try replaceMeasure(at: measureIndex + 1, with: secondMeasure)
         } else {
-            secondMeasure = nil
-        }
-
-        // Modify tie
-        if secondMeasure != nil {
-            try firstMeasure.modifyTie(at: noteIndex, requestedTieState: removeTie ? nil : .begin )
-            try secondMeasure?.modifyTie(at: 0, requestedTieState: removeTie ? nil : .end)
-        } else {
-            if removeTie {
-                try firstMeasure.removeTie(at: noteIndex)
-            } else {
-                try firstMeasure.startTie(at: noteIndex)
-            }
-        }
-
-        // Set new measures in the staff
+			if removeTie {
+				try firstMeasure.removeTie(at: noteIndex)
+			} else {
+				try firstMeasure.startTie(at: noteIndex)
+			}
+        }
+		
         try replaceMeasure(at: measureIndex, with: firstMeasure)
-        if let secondMeasure = secondMeasure {
-            try replaceMeasure(at: measureIndex + 1, with: secondMeasure)
-        }
     }
 
     internal func notesHolderIndexFromMeasureIndex(_ index: Int) throws -> (notesHolderIndex: Int, repeatMeasureIndex: Int?) {

    case noNextNote
    case notBeginningOfTie
    case repeatedMeasureCannotHaveTie
    case measureNotPartOfRepeat
    case repeatedMeasureCannotBeModified
    case cannotInsertRepeatWhereOneAlreadyExists

            throw StaffError.noteIndexOutOfRange
        }

        if noteIndex == firstMeasure.noteCount - 1 {
            let secondNotesHolderIndex: (notesHolderIndex: Int, repeatMeasureIndex: Int?)
            do {
