Further vectorizations
Vectorized some computations