Fixed NullPointerException issues if activities get killed by Android.