Is there a reason you're not restoring the original position of the cursor immediately? Seems to me waiting until other cursors are modified could cause cursors to be misplaced when restored due to shifted text.