Getting org switcher functional and some related refactorings, fixes #2189.