 {
   __shared__ float scratch[BLOCK_SIZE * 2];
 
-  // Initialize output to 0.
-  if (gid == 0)
-    *gswing = 0;
-
   // Setup local data to perform reduction.
   unsigned int tx = threadIdx.x;
   unsigned int base = tx + (blockIdx.x * BLOCK_SIZE * 2);

    float* oldGraphSpeed)
{
  unsigned int gid = threadIdx.x + (blockIdx.x * BLOCK_SIZE);
  float graphSpeed = *oldGraphSpeed;

  float forceX = 0.0;
  float forceY = 0.0;

  float dispX = 0.0;
  float dispY = 0.0;

  float speed = 0.0;

  // Update speed of Graph.
  fa2UpdateSpeedGraph(*graphSwing, *graphTract, &graphSpeed);

  if (gid == 0)
  {
    *oldGraphSpeed = graphSpeed;
    *graphSwing = 0.0;
    *graphTract = 0.0;
  }

  // Gravity force
  fa2Gravity(gid, numvertices, vxLocs, vyLocs, &forceX, &forceY, numNeighbours);
  // Repulsion between vertices
  fa2Repulsion(gid, numvertices, vxLocs, vyLocs, &forceX, &forceY, numNeighbours);
  // Attraction on edges
  fa2Attraction(gid, numvertices, vxLocs, vyLocs, numedges, edgeSources,
      edgeTargets, &forceX, &forceY);

  // Calculate speed of vertices.
  // Update swing of vertices.
  fa2UpdateSwing(gid, numvertices, forceX, forceY, oldForceX, oldForceY, swg);

  // Update traction of vertices.
  fa2UpdateTract(gid, numvertices, forceX, forceY, oldForceX, oldForceY, tra);

  // Update speed of vertices.
  fa2UpdateSpeed(gid, numvertices, &speed, swg, forceX, forceY, graphSpeed);

  // Update displacement of vertices.
  fa2UpdateDisplacement(gid, numvertices, speed, forceX, forceY, &dispX, &dispY);

  // Set current forces as old forces in vertex data.
  fa2SaveOldForces(gid, numvertices, forceX, forceY, oldForceX, oldForceY);

  // Update vertex locations based on speed.
  // TODO Add a barrier here to make sure no vertex location is update before
  // all vertices have calculated their repulsion and attraction forces.
  fa2UpdateLocation(gid, numvertices, vxLocs, vyLocs, dispX, dispY);
}

void fa2RunOnGraph(Graph* g, unsigned int iterations)

  {
    // Run fa2 spring embedding kernel.

    //cudaEventCreate(&start);
    //cudaEventRecord(start, 0);

    *graphSwing = *graphTract = 0; 

    // Run reductions on vertex swing and traction.
    fa2GraphSwingTract<<<numblocks_reduction, BLOCK_SIZE>>>(
