Document demo script, and refactor.

The demo script had almost no documentation, so add it.
The demo script's layout was "as coded" but some slight refactoring
makes it easier to read.