cleanup: use type switches where appropriate

See http://golang.org/doc/effective_go.html#type_switch for reference, if needed. These are pretty cool.