Improve matrix handling.