           pd++;
 
           if (n >= 0) {
-            dx = posxd[n] - px;
-            dy = posyd[n] - py;
+            dx = px - posxd[n];
+            dy = py - posyd[n];
             // tmp = dx*dx + dy*dy; // distance squared
             tmp = dx*dx + dy*dy + epssqd; // distance squared plus small constant to prevent zeros
             if ((n < nbodiesd) || __all(tmp < dq[depth])) {  // check if all threads agree that cell is far enough away (or is a body)

  // TODO: fix momentum at step 0
  inc = blockDim.x * gridDim.x;
  for (i = threadIdx.x + blockIdx.x * blockDim.x; i < N; i += inc) {
      tmpx = 4.0f * (attr_forces[i] + (rep_forces[i] / norm));
      tmpy = 4.0f * (attr_forces[i + N] + (rep_forces[nnodes + 1 + i] / norm));
      tmpx = momentum * tmpx + (1 - momentum) * old_forces[i];
      tmpy = momentum * tmpy + (1 - momentum) * old_forces[i + N];
      pts[i] -= eta * tmpx;

              // from sptree.cpp
              tmp = 1 / (1 + tmp);
              mult = massd[n] * tmp;
              // printf("%0.2f\n", massd[n]);
              normsum += mult;
              mult *= tmp;
              vx += dx * mult;
