matrix performance improvements