Finally, a significant speed update: efficient (vectorized) computation
of M and r