refactoring of palette rendering.