             telescope->station_z.location() != OSKAR_LOCATION_GPU)
         return OSKAR_ERR_BAD_LOCATION;
 
-    // Check that the data is of the right type.
+    // Get data sizes.
+    const int n_sources  = K->n_sources();
+    const int n_stations = K->n_stations();
+
+    // Evaluate Jones matrix.
     if (K->type() == OSKAR_SINGLE_COMPLEX)
     {
+        // Check that the data is of the right type.
         if (sky->rel_l.type() != OSKAR_SINGLE ||
         		sky->rel_m.type() != OSKAR_SINGLE ||
         		sky->rel_n.type() != OSKAR_SINGLE ||

        		(const float*)sky->rel_n.data,
        		(float2*)K->ptr.data);
    }
    else if (K->type() == OSKAR_DOUBLE_COMPLEX_MATRIX)
    {
    	// Evaluate Greenwich Hour Angle of phase centre.
    	const double ha0 = gast - telescope->ra0;
    	const double dec0 = telescope->dec0;

        		telescope->station_y.type() != OSKAR_SINGLE ||
        		telescope->station_z.type() != OSKAR_SINGLE)
            return OSKAR_ERR_TYPE_MISMATCH;

    	// Evaluate Greenwich Hour Angle of phase centre.
    	const float ha0 = (float)(gast - telescope->ra0);
    	const float dec0 = (float)telescope->dec0;
