Refactor code relating to navigation between terms.