Made a few functions more numpy-reliant, boosting speed.