Fix matrix inversion, fix code style issue