Plodding onward.  This is going to get repetitive.
diff --git a/OpenSSL/crypto/x509.c b/OpenSSL/crypto/x509.c
index daae351..2f12437 100644
--- a/OpenSSL/crypto/x509.c
+++ b/OpenSSL/crypto/x509.c
@@ -30,7 +30,7 @@
     if (!PyArg_ParseTuple(args, ":get_version"))
         return NULL;
 
-    return PyInt_FromLong((long)X509_get_version(self->x509));
+    return PyLong_FromLong((long)X509_get_version(self->x509));
 }
 
 static char crypto_X509_set_version_doc[] = "\n\
@@ -102,21 +102,13 @@
         return NULL;
     }
 
-    if (!PyInt_Check(serial) && !PyLong_Check(serial)) {
+    if (!PyLong_Check(serial)) {
         PyErr_SetString(
             PyExc_TypeError, "serial number must be integer");
         goto err;
     }
 
-    if ((format_args = Py_BuildValue("(O)", serial)) == NULL) {
-        goto err;
-    }
-
-    if ((format = PyString_FromString("%x")) == NULL) {
-        goto err;
-    }
-
-    if ((hex = PyString_Format(format, format_args)) == NULL) {
+    if ((hex = PyNumber_ToBase(serial, 16)) == NULL) {
         goto err;
     }
 
@@ -125,7 +117,7 @@
      * it.  If bignum is still NULL after this call, then the return value
      * is actually the result.  I hope.  -exarkun
      */
-    small_serial = BN_hex2bn(&bignum, PyString_AsString(hex));
+    small_serial = BN_hex2bn(&bignum, PyBytes_AsString(hex));
 
     Py_DECREF(format_args);
     format_args = NULL;
@@ -418,14 +410,14 @@
 	    Py_INCREF(Py_None);
 	    return Py_None;
 	} else if (timestamp->type == V_ASN1_GENERALIZEDTIME) {
-		return PyString_FromString((char *)timestamp->data);
+		return PyBytes_FromString((char *)timestamp->data);
 	} else {
 		ASN1_TIME_to_generalizedtime(timestamp, &gt_timestamp);
 		if (gt_timestamp == NULL) {
 			exception_from_error_queue(crypto_Error);
 			return NULL;
 		} else {
-			py_timestamp = PyString_FromString((char *)gt_timestamp->data);
+			py_timestamp = PyBytes_FromString((char *)gt_timestamp->data);
 			ASN1_GENERALIZEDTIME_free(gt_timestamp);
 			return py_timestamp;
 		}
@@ -582,9 +574,9 @@
 
     tnow = time(NULL);
     if (ASN1_UTCTIME_cmp_time_t(X509_get_notAfter(self->x509), tnow) < 0)
-        return PyInt_FromLong(1L);
+        return PyLong_FromLong(1L);
     else
-        return PyInt_FromLong(0L);
+        return PyLong_FromLong(0L);
 }
 
 static char crypto_X509_subject_name_hash_doc[] = "\n\
@@ -637,7 +629,7 @@
         sprintf(tmp+i*3,"%02X:",fp[i]);
     }
     tmp[3*len-1] = 0;
-    ret = PyString_FromStringAndSize(tmp,3*len-1);
+    ret = PyBytes_FromStringAndSize(tmp,3*len-1);
     free(tmp);
     return ret;
 }
@@ -783,20 +775,6 @@
     PyObject_Del(self);
 }
 
-/*
- * Find attribute
- *
- * Arguments: self - The X509 object
- *            name - The attribute name
- * Returns:   A Python object for the attribute, or NULL if something went
- *            wrong
- */
-static PyObject *
-crypto_X509_getattr(crypto_X509Obj *self, char *name)
-{
-    return Py_FindMethod(crypto_X509_methods, (PyObject *)self, name);
-}
-
 PyTypeObject crypto_X509_Type = {
     PyObject_HEAD_INIT(NULL)
     0,
@@ -805,7 +783,7 @@
     0,
     (destructor)crypto_X509_dealloc,
     NULL, /* print */
-    (getattrfunc)crypto_X509_getattr,
+    NULL, /* getattr */
     NULL, /* setattr */
     NULL, /* compare */
     NULL, /* repr */
diff --git a/OpenSSL/crypto/x509ext.h b/OpenSSL/crypto/x509ext.h
index f20e562..6ce7f68 100644
--- a/OpenSSL/crypto/x509ext.h
+++ b/OpenSSL/crypto/x509ext.h
@@ -19,8 +19,9 @@
 
 extern  PyTypeObject      crypto_X509Extension_Type;
 
-#define crypto_X509Extension_Check(v) ((v)->ob_type == \
-				       &crypto_X509Extension_Type)
+#define crypto_X509Extension_Check(v) ( \
+        PyObject_TypeCheck((v),         \
+                           &crypto_X509Extension_Type))
 
 typedef struct {
     PyObject_HEAD
diff --git a/OpenSSL/py3k.h b/OpenSSL/py3k.h
index a9e8e5c..55bcfda 100644
--- a/OpenSSL/py3k.h
+++ b/OpenSSL/py3k.h
@@ -16,6 +16,7 @@
 #define PyBytes_FromStringAndSize PyString_FromStringAndSize
 
 #define PyLong_FromLong PyInt_FromLong
+#define PyLong_Check(o) (PyInt_Check(o) || PyLong_Check(o))
 
 #define PyBytes_Size PyString_Size
 #define PyBytes_Check PyString_Check