Fix main activity lifecycle and etc.