use hasattr for attribute checks
use ininstance for type checks

type(x) == y is not safe in the face of inheritance.
remove unused variables and imports

Use pyflake to find these.
Merge pull request #17 from larsmans/minor-fixes

Minor fixes