Squash obvious pep8 stuff
use isinstance() for all type checks.

Python types inherit from each other; bool's are numbers and strings are sequences; so they are special cased.