fix math
TO DO: remove ugly code, rewrite Matrix::invert() method