Vectorized np.percentil use
Switched to vectorized use of np.percentile where appropriate
Cleaned up some excessively verbose code