Removed an unnecessary allocation.
Fixed an oversight involving an index calculation, and a horribly-wrong matrix multiplication implementation.