matrix: make the code clearer
matrix: fix compilation issues