Factor out list layout code.