Start of a bit of refactoring to accommodate views,
and DRY things a bit.