Refactor code to build up breadcrumb trails

Per #244.