Made some matrix quadratic forms way more memory efficient.