matrix bug fixes
fixing more matrix code