matrix arithmetics fixes