Improved version of previous commit, using SETTINGS values.