     cudaMemcpy(d_delta1, h_delta1, size_of_galaxy_array, cudaMemcpyHostToDevice );
 
     int x, y;
-    int num_submatrices = NUM_GALAXIES / SUBMATRIX_SIZE;
+    int num_submatrices = NUM_GALAXIES1 / SUBMATRIX_SIZE;
 
     // Take care of edges of matrix.
     if (NUM_GALAXIES%SUBMATRIX_SIZE != 0)

    float *d_alpha1, *d_delta1;
    float *h_alpha1, *h_delta1;

    int NUM_GALAXIES;

    //////////////////////////////////////////////////////////////////////
    // Read in the galaxy files.

    // Read in the first file
    ////////////////////////////////////////////////////////////////////////////

    fscanf(infile0, "%d", &NUM_GALAXIES0);

    int size_of_galaxy_array = NUM_GALAXIES0 * sizeof(float);    
    printf("SIZE 0 # GALAXIES: %d\n",NUM_GALAXIES0);

    h_alpha0 = (float*)malloc(size_of_galaxy_array);
    h_delta0 = (float*)malloc(size_of_galaxy_array);
    float temp0, temp1;

    for(int i=0; i<NUM_GALAXIES0; i++)
    {
        fscanf(infile0, "%f %f", &temp0, &temp1);
        h_alpha0[i] = temp0/scale_factor;
