Some cleanups to new merge_setting function