Fix matrices being column-major