Initial work on setting up matrices etc