Better app startup and error handling logic