Add code to generate plots.
Minor tidying.