Don't compare string
Fix version check
Handle objects and codes explictly
Fix metaclass for 3
Missing import
Use hasattr
Use items