MADS: Reduce the scope of some variables in Palette