Some cleanups in the plotting code