Performance improvement for Matrix3D