Fix profiling code
use numpy arrays for speed
standardize to mean 0