save config after changing variables
refactored merge variables function (also fixed bleeding variables)