ColorBrewer.getPalette(name) is case senstive, so if it return null try searching by name with out respect to case.  Also, don't set palette.maxColors if palette is null.