Replace huge switch statement by a lookup table.