         int vi_s = batch_no*nbaseline*npol+pol_no;
         int grid_s = batch_no*npol*gridsize*gridsize + pol_no*gridsize*gridsize;
         int vi = 0;
-        for(vi = 0; vi < (nbaseline); vi+=npol) {
-
-	    int xl = xdata[vi];
-	    int yl = ydata[vi];
+        for(vi = 0; vi < (nbaseline*npol); vi+=npol) {
+	        int xl = xdata[vi];
+	        int yl = ydata[vi];
 
             // Determine convolution point. This is basically just an
             // optimised way to calculate.

                                 int      gridsize, 
                                 int      nbatch,
                                 int*     xpos,
				 int*     ypos,
				 int*     zpos,
                                 OutType* kernels,
                                 InType*  d_in,
                                 OutType* d_out,

			      const InType* __restrict__  d_in,
			      OutType*                    d_out) {
    int batch_no = blockIdx.x;
    int pol_no = threadIdx.y;
    
    for(int i = threadIdx.x; i < maxsupport * maxsupport; i += blockDim.x) {
        int myU = i % maxsupport;
        int myV = i / maxsupport;
