Fix crash on startup and on the settings page