Fix matrix operations according to changed API