Add support for calculating palette numbers