Added activity/fragment state functionality