Minor refactoring of matrix printing