migrated abs/fabs to std::abs
moved maxDeltaR2 calculation outside a double for loop