Fix an issue when changing settings. Fixes #1921