Fixed bugs, sped up plotting and ensured ordering is correct