improve perf by using type-switch instead of attempting a bunch of casts
Merge pull request #40 from ryansb/ifToSwitch

Improve perf by using type-switch instead of attempting a bunch of casts