Refactored app bootstrap logic.