Fix all long() to int() and fix types.XXXType to isinstance()