Merge "Palette code cleanup:" into nextgenv2