Fixed bugs with Matrix math. Closes #1.