Refactor the palette reader