Add matrix traits, do lots of reorganisation/re-formatting