Vectorize rank computations
More performance improvements, this runs in an hour now instead of 5 days