 
         if (threadIdx.x == 0) {
 		    y = g_new;
-            cudaDeviceSynchronize();
             // Update line direction
 		    subtract_change(y, g, n);
 
 		    prevf0 = f0;
 		    f0 = f1;
 		    x = x_new;
-            cudaDeviceSynchronize();
         }
 
 		if (params.early_term)

            if (idx == 0) {
			    x_new = x;
			    g_new.clear(); //dkoes - set gradient to zero
                cudaDeviceSynchronize();
            }
            //TODO: unnecessary? are memset calls issued to the default stream?
			return 0;
		}
		else if (f1 <= f0 + ALF * alpha * slope)

	{
        if (idx == 0) {
		    x_new = x;
        }
        __syncthreads();
        if (idx < x_new.n)
