minor fixes around matrix preperation