First wave of optimizations.

use a switch(){}, adjust indentation