Change if-elseif to switch.
More cleanups.