Added saving of activity's state.