The logic to detect and attempt to fix ID switches is unfortunately a huge part of multi-object tracking.