Fix race condition in settings page