fixes to the plotting code