Added an implementation of quaternions and refactored matrix.