Matrix4 improvement

Resolves #968. Completes the `Matrix4` class and converts the library to using it internally rather than double/float arrays.