Refactored element-ID logic, gathering funcs, etc.

Moving lots of common logic (per NexSON element type) to the viewModel,
along with other ephemeral data that gets cleared when the load a fresh
NexSON study.