added update_persistent_mode and other helper functions