tidied matrix calculation up
started reimplementing materials