bugfixes with matrices