Refactor demo code a bit to eliminate duplication of code for
generating the page layout.