Initial implementation of marix - commenting and tidying up still to do