Updated to have support for generic functions, and implement the matrix inversion using wrappers.