Adjusted switch case to place most frequently called case first, for
efficiency.