Removed code duplication for setting up window and rootviewcontroller