Merge main repo.
Merge main repo.
minor refactor.
update so issue 657 can be closed (see issue for more details).
Merge main repo