Trajectory Alignment and Repairing