Code refactoring and app selection tweaks