Updated BaseApp to handle main loop.