Improve matrix classes