Added app selection dialog, cleaned up code