Convert mda stuff to matrix operations. Good speedup. Using numpy for matrix operations.