Reorder class definition to allow special classes for empty and overflowing values
Improve legend class computation