added matrix operations and misc changes