Cleaning up plot code