Tikz code revamped. Uses the new layer algorithm to calculate xy-coords and I have added some of the cases for the arrows that are to be made so that they are nicely rounded