This version follows Wanyi's thesis in terms of parameterization, it  has just been restructured to be easier to use