Fix compare methods and use type_code in __cmp__

But this is not a big issue.