More main activity lifecycle fixes