fixed a bug in which AppMain.application is not set until after the context starts