Replace giant if...elif with a dictionary.