matrix bugfixes