Fix thread end_pos