     uint8_t thinning_cond_4 = (((P2 & P4 & P6) == 0) | (TR_P4 != 1));
     uint8_t thinning_cond_ok = thinning_cond_1 & thinning_cond_2 & thinning_cond_3 & thinning_cond_4;
 
-    dst[row * width + col] = BINARY_WHITE + ((1 - thinning_cond_ok) * src[row * width + col]);
+    d_dst[row * width + col] = BINARY_WHITE + ((1 - thinning_cond_ok) * d_src[row * width + col]);
 }
 
 // Computes the number of white to black transitions around a pixel.
-__device__ uint8_t wb_transitions_around(uint8_t* data, unsigned int row, unsigned int col, unsigned int width) {
+__device__ uint8_t wb_transitions_around(uint8_t* d_data, unsigned int row, unsigned int col, unsigned int width) {
     uint8_t count = 0;
 
-    count += ( (P2(data, row, col, width) == BINARY_WHITE) & (P3(data, row, col, width) == BINARY_BLACK) );
-    count += ( (P3(data, row, col, width) == BINARY_WHITE) & (P4(data, row, col, width) == BINARY_BLACK) );
-    count += ( (P4(data, row, col, width) == BINARY_WHITE) & (P5(data, row, col, width) == BINARY_BLACK) );
-    count += ( (P5(data, row, col, width) == BINARY_WHITE) & (P6(data, row, col, width) == BINARY_BLACK) );
-    count += ( (P6(data, row, col, width) == BINARY_WHITE) & (P7(data, row, col, width) == BINARY_BLACK) );
-    count += ( (P7(data, row, col, width) == BINARY_WHITE) & (P8(data, row, col, width) == BINARY_BLACK) );
-    count += ( (P8(data, row, col, width) == BINARY_WHITE) & (P9(data, row, col, width) == BINARY_BLACK) );
-    count += ( (P9(data, row, col, width) == BINARY_WHITE) & (P2(data, row, col, width) == BINARY_BLACK) );
+    count += ( (P2(d_data, row, col, width) == BINARY_WHITE) & (P3(d_data, row, col, width) == BINARY_BLACK) );
+    count += ( (P3(d_data, row, col, width) == BINARY_WHITE) & (P4(d_data, row, col, width) == BINARY_BLACK) );
+    count += ( (P4(d_data, row, col, width) == BINARY_WHITE) & (P5(d_data, row, col, width) == BINARY_BLACK) );
+    count += ( (P5(d_data, row, col, width) == BINARY_WHITE) & (P6(d_data, row, col, width) == BINARY_BLACK) );
+    count += ( (P6(d_data, row, col, width) == BINARY_WHITE) & (P7(d_data, row, col, width) == BINARY_BLACK) );
+    count += ( (P7(d_data, row, col, width) == BINARY_WHITE) & (P8(d_data, row, col, width) == BINARY_BLACK) );
+    count += ( (P8(d_data, row, col, width) == BINARY_WHITE) & (P9(d_data, row, col, width) == BINARY_BLACK) );
+    count += ( (P9(d_data, row, col, width) == BINARY_WHITE) & (P2(d_data, row, col, width) == BINARY_BLACK) );
 
     return count;
 }

    pad_binary_bitmap(&dst_bitmap, BINARY_WHITE, padding);

    // allocate memory on device
    // TODO

    // iterative thinning algorithm
    unsigned int iterations = 0;
    // do {
    //     skeletonize_pass<<<grid_dim, block_dim>>>(src_bitmap->data, dst_bitmap->data, src_bitmap->width, src_bitmap->height, padding);
    //     swap_bitmaps(&src_bitmap, &dst_bitmap);

    //     iterations++;
    //     printf(".");
    //     fflush(stdout);
    // } while (!are_identical_bitmaps(src_bitmap, dst_bitmap));

    // Remove extra padding that was added to the images (don't care about
    // src_bitmap, so only need to unpad dst_bitmap)

}

// Performs 1 iteration of the thinning algorithm.
__global__ void skeletonize_pass(uint8_t* d_src, uint8_t* d_dst, unsigned int width, unsigned int height, Padding padding) {
    unsigned int row = blockIdx.y * blockDim.y + threadIdx.y + padding.top;
    unsigned int col = blockIdx.x * blockDim.x + threadIdx.x + padding.left;

    uint8_t NZ = black_neighbors_around(d_src, row, col, width);
    uint8_t TR_P1 = wb_transitions_around(d_src, row, col, width);
    uint8_t TR_P2 = wb_transitions_around(d_src, row-1, col, width);
    uint8_t TR_P4 = wb_transitions_around(d_src, row, col-1, width);
    uint8_t P2 = P2(d_src, row, col, width);
    uint8_t P4 = P4(d_src, row, col, width);
    uint8_t P6 = P6(d_src, row, col, width);
    uint8_t P8 = P8(d_src, row, col, width);

    uint8_t thinning_cond_1 = ((2 <= NZ) & (NZ <= 6));
    uint8_t thinning_cond_2 = (TR_P1 == 1);
