Make the flow types fixed and add more optimisation passes