fixes for matrixlib, forgot to commit, possibly unstable