Rewrite of the entire legend documentation, including tidy ups of code
and style to all things "legend".