Fix incorrect matrix conversion