Refactored app initialization and request handling.