  * @param p_face_cnt The number of faces in the mesh.
  */
 __global__ void InitEdges(const uint3* p_faces, SombreroKernels::Edge* p_edges, uint p_face_cnt) {
-    const uint idx = GetThreadIndex();
+    const uint idx = GetCurThreadIndex();
     if (idx >= p_face_cnt) return;
 
     // First edge.

 */
__global__ void MatchEdges(
    SombreroKernels::Edge* p_edges, SombreroKernels::Edge* p_sorted_edges, uint* p_edge_offset, uint p_edge_cnt) {
    const uint idx = GetThreadIndex();
    if (idx >= p_edge_cnt) return;

    // Get current edge and check if it is already matched.

 */
__global__ void SortNeighbourIds(uint* p_neighbour_ids, uint* p_neighbour_ids_offset, bool* p_valid_z_values,
    const uint* p_vertex_edge_offset_depth, const int* p_vertex_type, uint p_vertex_cnt, uint p_edge_cnt) {
    const uint idx = GetCurThreadIndex();
    if (idx >= p_vertex_cnt) return;
    if (!p_valid_z_values[idx]) return;

