many fixes in math done in AMMatrix