only run if setting is a change, and fix several bugs