Commits

James Taylor  committed 0129222

Cython intersection.pyx -> intersection.c

  • Participants
  • Parent commits 130f083

Comments (0)

Files changed (1)

File lib/bx/intervals/intersection.c

-/* Generated by Cython 0.10.3 on Sun Mar  1 17:29:36 2009 */
+/* Generated by Cython 0.11.1 on Mon Apr 27 13:39:35 2009 */
 
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"
 #include "structmember.h"
+#ifndef Py_PYTHON_H
+    #error Python headers needed to compile C extensions, please install development version of Python.
+#endif
 #ifndef PY_LONG_LONG
   #define PY_LONG_LONG LONG_LONG
 #endif
 #endif
 #if PY_VERSION_HEX < 0x02040000
   #define METH_COEXIST 0
+  #define PyDict_CheckExact(op) (Py_TYPE(op) == &PyDict_Type)
 #endif
 #if PY_VERSION_HEX < 0x02050000
   typedef int Py_ssize_t;
   #define PY_SSIZE_T_MAX INT_MAX
   #define PY_SSIZE_T_MIN INT_MIN
+  #define PY_FORMAT_SIZE_T ""
   #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
   #define PyInt_AsSsize_t(o)   PyInt_AsLong(o)
   #define PyNumber_Index(o)    PyNumber_Int(o)
 
   #define PyBUF_SIMPLE 0
   #define PyBUF_WRITABLE 0x0001
-  #define PyBUF_LOCK 0x0002
   #define PyBUF_FORMAT 0x0004
   #define PyBUF_ND 0x0008
   #define PyBUF_STRIDES (0x0010 | PyBUF_ND)
 #if PY_MAJOR_VERSION >= 3
   #define PyBaseString_Type            PyUnicode_Type
   #define PyString_Type                PyBytes_Type
+  #define PyString_CheckExact          PyBytes_CheckExact
   #define PyInt_Type                   PyLong_Type
   #define PyInt_Check(op)              PyLong_Check(op)
   #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
 #else
   #define _USE_MATH_DEFINES
 #endif
+#if PY_VERSION_HEX < 0x02050000
+  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),((char *)(n)))
+  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a))
+  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),((char *)(n)))
+#else
+  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),(n))
+  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a))
+  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),(n))
+#endif
+#if PY_VERSION_HEX < 0x02050000
+  #define __Pyx_NAMESTR(n) ((char *)(n))
+  #define __Pyx_DOCSTR(n)  ((char *)(n))
+#else
+  #define __Pyx_NAMESTR(n) (n)
+  #define __Pyx_DOCSTR(n)  (n)
+#endif
 #ifdef __cplusplus
 #define __PYX_EXTERN_C extern "C"
 #else
 /* Type Conversion Predeclarations */
 
 #if PY_MAJOR_VERSION < 3
-#define __Pyx_PyBytes_FromString PyString_FromString
-#define __Pyx_PyBytes_AsString   PyString_AsString
+#define __Pyx_PyBytes_FromString          PyString_FromString
+#define __Pyx_PyBytes_FromStringAndSize   PyString_FromStringAndSize
+#define __Pyx_PyBytes_AsString            PyString_AsString
 #else
-#define __Pyx_PyBytes_FromString PyBytes_FromString
-#define __Pyx_PyBytes_AsString   PyBytes_AsString
+#define __Pyx_PyBytes_FromString          PyBytes_FromString
+#define __Pyx_PyBytes_FromStringAndSize   PyBytes_FromStringAndSize
+#define __Pyx_PyBytes_AsString            PyBytes_AsString
 #endif
 
 #define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
-static INLINE int __Pyx_PyObject_IsTrue(PyObject* x);
-static INLINE PY_LONG_LONG __pyx_PyInt_AsLongLong(PyObject* x);
-static INLINE unsigned PY_LONG_LONG __pyx_PyInt_AsUnsignedLongLong(PyObject* x);
-static INLINE Py_ssize_t __pyx_PyIndex_AsSsize_t(PyObject* b);
-
-#define __pyx_PyInt_AsLong(x) (PyInt_CheckExact(x) ? PyInt_AS_LONG(x) : PyInt_AsLong(x))
+static INLINE int __Pyx_PyObject_IsTrue(PyObject*);
+static INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);
+
+#if !defined(T_PYSSIZET)
+#if PY_VERSION_HEX < 0x02050000
+#define T_PYSSIZET T_INT
+#elif !defined(T_LONGLONG)
+#define T_PYSSIZET \
+        ((sizeof(Py_ssize_t) == sizeof(int))  ? T_INT  : \
+        ((sizeof(Py_ssize_t) == sizeof(long)) ? T_LONG : -1))
+#else
+#define T_PYSSIZET \
+        ((sizeof(Py_ssize_t) == sizeof(int))          ? T_INT      : \
+        ((sizeof(Py_ssize_t) == sizeof(long))         ? T_LONG     : \
+        ((sizeof(Py_ssize_t) == sizeof(PY_LONG_LONG)) ? T_LONGLONG : -1)))
+#endif
+#endif
+
+#if !defined(T_SIZET)
+#if !defined(T_ULONGLONG)
+#define T_SIZET \
+        ((sizeof(size_t) == sizeof(unsigned int))  ? T_UINT  : \
+        ((sizeof(size_t) == sizeof(unsigned long)) ? T_ULONG : -1))
+#else
+#define T_SIZET \
+        ((sizeof(size_t) == sizeof(unsigned int))          ? T_UINT      : \
+        ((sizeof(size_t) == sizeof(unsigned long))         ? T_ULONG     : \
+        ((sizeof(size_t) == sizeof(unsigned PY_LONG_LONG)) ? T_ULONGLONG : -1)))
+#endif
+#endif
+
+static INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
+static INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
+static INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*);
+
 #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
 
-static INLINE unsigned char __pyx_PyInt_unsigned_char(PyObject* x);
-static INLINE unsigned short __pyx_PyInt_unsigned_short(PyObject* x);
-static INLINE char __pyx_PyInt_char(PyObject* x);
-static INLINE short __pyx_PyInt_short(PyObject* x);
-static INLINE int __pyx_PyInt_int(PyObject* x);
-static INLINE long __pyx_PyInt_long(PyObject* x);
-static INLINE signed char __pyx_PyInt_signed_char(PyObject* x);
-static INLINE signed short __pyx_PyInt_signed_short(PyObject* x);
-static INLINE signed int __pyx_PyInt_signed_int(PyObject* x);
-static INLINE signed long __pyx_PyInt_signed_long(PyObject* x);
-static INLINE long double __pyx_PyInt_long_double(PyObject* x);
+
 #ifdef __GNUC__
 /* Test for GCC > 2.95 */
 #if __GNUC__ > 2 ||               (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)) 
 static const char *__pyx_filename;
 static const char **__pyx_f;
 
-static char __pyx_mdoc[] = "\nData structure for performing intersect queries on a set of intervals which\npreserves all information about the intervals (unlike bitset projection methods).\n\n:Authors: James Taylor (james@jamestaylor.org),\n          Ian Schenk (ian.schenck@gmail.com),\n          Brent Pederson (bpederse@gmail.com)\n";
+static char __pyx_mdoc[] = "\nData structure for performing intersect queries on a set of intervals which\npreserves all information about the intervals (unlike bitset projection methods).\n\n:Authors: James Taylor (james@jamestaylor.org),\n          Ian Schenk (ian.schenck@gmail.com),\n          Brent Pedersen (bpederse@gmail.com)\n";
+
+#ifdef CYTHON_REFNANNY
+typedef struct {
+  void (*INCREF)(void*, PyObject*, int);
+  void (*DECREF)(void*, PyObject*, int);
+  void (*GOTREF)(void*, PyObject*, int);
+  void (*GIVEREF)(void*, PyObject*, int);
+  void* (*NewContext)(const char*, int, const char*);
+  void (*FinishContext)(void**);
+} __Pyx_RefnannyAPIStruct;
+static __Pyx_RefnannyAPIStruct *__Pyx_Refnanny = NULL;
+#define __Pyx_ImportRefcountAPI(name)   (__Pyx_RefnannyAPIStruct *) PyCObject_Import((char *)name, (char *)"RefnannyAPI")
+#define __Pyx_INCREF(r) __Pyx_Refnanny->INCREF(__pyx_refchk, (PyObject *)(r), __LINE__)
+#define __Pyx_DECREF(r) __Pyx_Refnanny->DECREF(__pyx_refchk, (PyObject *)(r), __LINE__)
+#define __Pyx_GOTREF(r) __Pyx_Refnanny->GOTREF(__pyx_refchk, (PyObject *)(r), __LINE__)
+#define __Pyx_GIVEREF(r) __Pyx_Refnanny->GIVEREF(__pyx_refchk, (PyObject *)(r), __LINE__)
+#define __Pyx_XDECREF(r) if((r) == NULL) ; else __Pyx_DECREF(r)
+#define __Pyx_SetupRefcountContext(name)   void* __pyx_refchk = __Pyx_Refnanny->NewContext((name), __LINE__, __FILE__)
+#define __Pyx_FinishRefcountContext()   __Pyx_Refnanny->FinishContext(&__pyx_refchk)
+#else
+#define __Pyx_INCREF(r) Py_INCREF(r)
+#define __Pyx_DECREF(r) Py_DECREF(r)
+#define __Pyx_GOTREF(r)
+#define __Pyx_GIVEREF(r)
+#define __Pyx_XDECREF(r) Py_XDECREF(r)
+#define __Pyx_SetupRefcountContext(name)
+#define __Pyx_FinishRefcountContext()
+#endif /* CYTHON_REFNANNY */
+#define __Pyx_XGIVEREF(r) if((r) == NULL) ; else __Pyx_GIVEREF(r)
+#define __Pyx_XGOTREF(r) if((r) == NULL) ; else __Pyx_GOTREF(r)
 
 static void __Pyx_RaiseDoubleKeywordsError(
     const char* func_name, PyObject* kw_name); /*proto*/
 
 static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],     PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,     const char* function_name); /*proto*/
 
+static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/
+
 static INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict,
     const char* function_name, int kw_allowed); /*proto*/
 
 
 static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
 
-static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/
-
-static void __Pyx_WriteUnraisable(const char *name); /*proto*/
+static INLINE int __Pyx_StrEq(const char *, const char *); /*proto*/
+
+static INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *);
+
+static INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *);
+
+static INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *);
+
+static INLINE char __Pyx_PyInt_AsChar(PyObject *);
+
+static INLINE short __Pyx_PyInt_AsShort(PyObject *);
+
+static INLINE int __Pyx_PyInt_AsInt(PyObject *);
+
+static INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *);
+
+static INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *);
+
+static INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *);
+
+static INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *);
+
+static INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *);
+
+static INLINE long __Pyx_PyInt_AsLong(PyObject *);
+
+static INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *);
+
+static INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *);
+
+static INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *);
 
 static INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
 static INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
 
+static void __Pyx_WriteUnraisable(const char *name); /*proto*/
+
 static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/
 
 static void __Pyx_AddTraceback(const char *funcname); /*proto*/
 
 typedef char *__pyx_t_2bx_9intervals_12intersection_char_star;
 
-/* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":281
- *     ##     return [left, right]
+/* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":231
+ * 
  * 
  *     cpdef left(self, position, int n=1, int max_dist=2500):             # <<<<<<<<<<<<<<
  *         """
   int max_dist;
 };
 
-/* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":296
+/* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":246
  *         return r[:n]
  * 
  *     cpdef right(self, position, int n=1, int max_dist=2500):             # <<<<<<<<<<<<<<
   int max_dist;
 };
 
-/* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":60
+/* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":60
  * cdef float nlog = -1.0 / log(0.5)
  * 
  * cdef class IntervalNode:             # <<<<<<<<<<<<<<
  *     """
- *     Data structure for performing intersect and neighbor queries on a
+ *     A single node of an `IntervalTree`.
  */
 
 struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode {
   struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *croot;
 };
 
-/* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":357
+/* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":307
  *         return cmp( self.start, other.start ) or cmp( self.end, other.end )
  * 
  * cdef class IntervalTree:             # <<<<<<<<<<<<<<
   struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *root;
 };
 
-/* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":323
+/* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":273
  * ## ---- Wrappers that retain the old interface -------------------------------
  * 
  * cdef class Interval:             # <<<<<<<<<<<<<<
 };
 
 
-/* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":60
+/* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":60
  * cdef float nlog = -1.0 / log(0.5)
  * 
  * cdef class IntervalNode:             # <<<<<<<<<<<<<<
  *     """
- *     Data structure for performing intersect and neighbor queries on a
+ *     A single node of an `IntervalTree`.
  */
 
 struct __pyx_vtabstruct_2bx_9intervals_12intersection_IntervalNode {
 static PyTypeObject *__pyx_ptype_2bx_9intervals_12intersection_IntervalTree = 0;
 static float __pyx_v_2bx_9intervals_12intersection_nlog;
 static struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *__pyx_v_2bx_9intervals_12intersection_EmptyNode = 0;
-static PyObject *__pyx_k_3;
-static int __pyx_f_2bx_9intervals_12intersection_imax2(int, int); /*proto*/
-static int __pyx_f_2bx_9intervals_12intersection_imax3(int, int, int); /*proto*/
-static int __pyx_f_2bx_9intervals_12intersection_imin3(int, int, int); /*proto*/
-static int __pyx_f_2bx_9intervals_12intersection_imin2(int, int); /*proto*/
-
+static PyObject *__pyx_k_3 = 0;
+static INLINE int __pyx_f_2bx_9intervals_12intersection_imax2(int, int); /*proto*/
+static INLINE int __pyx_f_2bx_9intervals_12intersection_imax3(int, int, int); /*proto*/
+static INLINE int __pyx_f_2bx_9intervals_12intersection_imin3(int, int, int); /*proto*/
+static INLINE int __pyx_f_2bx_9intervals_12intersection_imin2(int, int); /*proto*/
+
+const char *__pyx_modulename = "bx.intervals.intersection";
 
 /* Implementation of bx.intervals.intersection */
 static PyObject *__pyx_int_0;
 static PyObject *__pyx_kp___init__;
 static char __pyx_k___cmp__[] = "__cmp__";
 static PyObject *__pyx_kp___cmp__;
+static char __pyx_k_add[] = "add";
+static PyObject *__pyx_kp_add;
 static char __pyx_k_before[] = "before";
 static PyObject *__pyx_kp_before;
 static char __pyx_k_after[] = "after";
 static PyObject *__pyx_kp_after;
 static char __pyx_k_insert_interval[] = "insert_interval";
 static PyObject *__pyx_kp_insert_interval;
+static char __pyx_k_add_interval[] = "add_interval";
+static PyObject *__pyx_kp_add_interval;
 static char __pyx_k_before_interval[] = "before_interval";
 static PyObject *__pyx_kp_before_interval;
 static char __pyx_k_after_interval[] = "after_interval";
 static PyObject *__pyx_kp_1;
 static char __pyx_k_2[] = "downstream_of_interval";
 static PyObject *__pyx_kp_2;
-static char __pyx_k_add[] = "add";
-static PyObject *__pyx_kp_add;
-static char __pyx_k_add_interval[] = "add_interval";
-static PyObject *__pyx_kp_add_interval;
 static char __pyx_k_start[] = "start";
 static PyObject *__pyx_kp_start;
 static char __pyx_k_end[] = "end";
 static PyObject *__pyx_kp_other;
 static char __pyx_k_num_intervals[] = "num_intervals";
 static PyObject *__pyx_kp_num_intervals;
+static char __pyx_k_fn[] = "fn";
+static PyObject *__pyx_kp_fn;
 static char __pyx_k_operator[] = "operator";
 static PyObject *__pyx_kp_operator;
 static char __pyx_k_Intersecter[] = "Intersecter";
 static PyObject *__pyx_kp_12;
 static char __pyx_k_12[] = "-";
 
-/* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":32
+/* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":32
  * ctypedef char * char_star
  * 
  * cdef inline int imax2(int a, int b):             # <<<<<<<<<<<<<<
 
 static INLINE int __pyx_f_2bx_9intervals_12intersection_imax2(int __pyx_v_a, int __pyx_v_b) {
   int __pyx_r;
-  int __pyx_1;
-
-  /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":33
+  int __pyx_t_1;
+  __Pyx_SetupRefcountContext("imax2");
+
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":33
  * 
  * cdef inline int imax2(int a, int b):
  *     if b > a: return b             # <<<<<<<<<<<<<<
  *     return a
  * 
  */
-  __pyx_1 = (__pyx_v_b > __pyx_v_a);
-  if (__pyx_1) {
+  __pyx_t_1 = (__pyx_v_b > __pyx_v_a);
+  if (__pyx_t_1) {
     __pyx_r = __pyx_v_b;
     goto __pyx_L0;
     goto __pyx_L3;
   }
   __pyx_L3:;
 
-  /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":34
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":34
  * cdef inline int imax2(int a, int b):
  *     if b > a: return b
  *     return a             # <<<<<<<<<<<<<<
 
   __pyx_r = 0;
   __pyx_L0:;
+  __Pyx_FinishRefcountContext();
   return __pyx_r;
 }
 
-/* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":36
+/* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":36
  *     return a
  * 
  * cdef inline int imax3(int a, int b, int c):             # <<<<<<<<<<<<<<
 
 static INLINE int __pyx_f_2bx_9intervals_12intersection_imax3(int __pyx_v_a, int __pyx_v_b, int __pyx_v_c) {
   int __pyx_r;
-  int __pyx_1;
-
-  /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":37
+  int __pyx_t_1;
+  __Pyx_SetupRefcountContext("imax3");
+
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":37
  * 
  * cdef inline int imax3(int a, int b, int c):
  *     if b > a:             # <<<<<<<<<<<<<<
  *         if c > b:
  *             return c
  */
-  __pyx_1 = (__pyx_v_b > __pyx_v_a);
-  if (__pyx_1) {
-
-    /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":38
+  __pyx_t_1 = (__pyx_v_b > __pyx_v_a);
+  if (__pyx_t_1) {
+
+    /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":38
  * cdef inline int imax3(int a, int b, int c):
  *     if b > a:
  *         if c > b:             # <<<<<<<<<<<<<<
  *             return c
  *         return b
  */
-    __pyx_1 = (__pyx_v_c > __pyx_v_b);
-    if (__pyx_1) {
-
-      /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":39
+    __pyx_t_1 = (__pyx_v_c > __pyx_v_b);
+    if (__pyx_t_1) {
+
+      /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":39
  *     if b > a:
  *         if c > b:
  *             return c             # <<<<<<<<<<<<<<
     }
     __pyx_L4:;
 
-    /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":40
+    /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":40
  *         if c > b:
  *             return c
  *         return b             # <<<<<<<<<<<<<<
   }
   __pyx_L3:;
 
-  /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":41
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":41
  *             return c
  *         return b
  *     if a > c:             # <<<<<<<<<<<<<<
  *         return a
  *     return c
  */
-  __pyx_1 = (__pyx_v_a > __pyx_v_c);
-  if (__pyx_1) {
-
-    /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":42
+  __pyx_t_1 = (__pyx_v_a > __pyx_v_c);
+  if (__pyx_t_1) {
+
+    /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":42
  *         return b
  *     if a > c:
  *         return a             # <<<<<<<<<<<<<<
   }
   __pyx_L5:;
 
-  /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":43
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":43
  *     if a > c:
  *         return a
  *     return c             # <<<<<<<<<<<<<<
 
   __pyx_r = 0;
   __pyx_L0:;
+  __Pyx_FinishRefcountContext();
   return __pyx_r;
 }
 
-/* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":45
+/* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":45
  *     return c
  * 
  * cdef inline int imin3(int a, int b, int c):             # <<<<<<<<<<<<<<
 
 static INLINE int __pyx_f_2bx_9intervals_12intersection_imin3(int __pyx_v_a, int __pyx_v_b, int __pyx_v_c) {
   int __pyx_r;
-  int __pyx_1;
-
-  /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":46
+  int __pyx_t_1;
+  __Pyx_SetupRefcountContext("imin3");
+
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":46
  * 
  * cdef inline int imin3(int a, int b, int c):
  *     if b < a:             # <<<<<<<<<<<<<<
  *         if c < b:
  *             return c
  */
-  __pyx_1 = (__pyx_v_b < __pyx_v_a);
-  if (__pyx_1) {
-
-    /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":47
+  __pyx_t_1 = (__pyx_v_b < __pyx_v_a);
+  if (__pyx_t_1) {
+
+    /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":47
  * cdef inline int imin3(int a, int b, int c):
  *     if b < a:
  *         if c < b:             # <<<<<<<<<<<<<<
  *             return c
  *         return b
  */
-    __pyx_1 = (__pyx_v_c < __pyx_v_b);
-    if (__pyx_1) {
-
-      /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":48
+    __pyx_t_1 = (__pyx_v_c < __pyx_v_b);
+    if (__pyx_t_1) {
+
+      /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":48
  *     if b < a:
  *         if c < b:
  *             return c             # <<<<<<<<<<<<<<
     }
     __pyx_L4:;
 
-    /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":49
+    /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":49
  *         if c < b:
  *             return c
  *         return b             # <<<<<<<<<<<<<<
   }
   __pyx_L3:;
 
-  /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":50
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":50
  *             return c
  *         return b
  *     if a < c:             # <<<<<<<<<<<<<<
  *         return a
  *     return c
  */
-  __pyx_1 = (__pyx_v_a < __pyx_v_c);
-  if (__pyx_1) {
-
-    /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":51
+  __pyx_t_1 = (__pyx_v_a < __pyx_v_c);
+  if (__pyx_t_1) {
+
+    /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":51
  *         return b
  *     if a < c:
  *         return a             # <<<<<<<<<<<<<<
   }
   __pyx_L5:;
 
-  /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":52
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":52
  *     if a < c:
  *         return a
  *     return c             # <<<<<<<<<<<<<<
 
   __pyx_r = 0;
   __pyx_L0:;
+  __Pyx_FinishRefcountContext();
   return __pyx_r;
 }
 
-/* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":54
+/* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":54
  *     return c
  * 
  * cdef inline int imin2(int a, int b):             # <<<<<<<<<<<<<<
 
 static INLINE int __pyx_f_2bx_9intervals_12intersection_imin2(int __pyx_v_a, int __pyx_v_b) {
   int __pyx_r;
-  int __pyx_1;
-
-  /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":55
+  int __pyx_t_1;
+  __Pyx_SetupRefcountContext("imin2");
+
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":55
  * 
  * cdef inline int imin2(int a, int b):
  *     if b < a: return b             # <<<<<<<<<<<<<<
  *     return a
  * 
  */
-  __pyx_1 = (__pyx_v_b < __pyx_v_a);
-  if (__pyx_1) {
+  __pyx_t_1 = (__pyx_v_b < __pyx_v_a);
+  if (__pyx_t_1) {
     __pyx_r = __pyx_v_b;
     goto __pyx_L0;
     goto __pyx_L3;
   }
   __pyx_L3:;
 
-  /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":56
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":56
  * cdef inline int imin2(int a, int b):
  *     if b < a: return b
  *     return a             # <<<<<<<<<<<<<<
 
   __pyx_r = 0;
   __pyx_L0:;
+  __Pyx_FinishRefcountContext();
   return __pyx_r;
 }
 
-/* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":115
+/* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":74
  * 
  *     property left_node:
  *         def __get__(self):             # <<<<<<<<<<<<<<
 
 static PyObject *__pyx_pf_2bx_9intervals_12intersection_12IntervalNode_9left_node___get__(PyObject *__pyx_v_self); /*proto*/
 static PyObject *__pyx_pf_2bx_9intervals_12intersection_12IntervalNode_9left_node___get__(PyObject *__pyx_v_self) {
-  PyObject *__pyx_r;
+  PyObject *__pyx_r = NULL;
   PyObject *__pyx_1 = 0;
-  int __pyx_2;
-
-  /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":116
+  int __pyx_t_1;
+  __Pyx_SetupRefcountContext("__get__");
+
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":75
  *     property left_node:
  *         def __get__(self):
  *             return self.cleft if self.cleft is not EmptyNode else None             # <<<<<<<<<<<<<<
  *     property right_node:
  *         def __get__(self):
  */
-  __pyx_2 = (((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self)->cleft != __pyx_v_2bx_9intervals_12intersection_EmptyNode);
-  if (__pyx_2) {
-    __pyx_1 = ((PyObject *)((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self)->cleft);
-    Py_INCREF(__pyx_1);
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = (((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self)->cleft != __pyx_v_2bx_9intervals_12intersection_EmptyNode);
+  if (__pyx_t_1) {
+    __Pyx_INCREF(((PyObject *)((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self)->cleft));
+    __pyx_1 = ((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self)->cleft;
   } else {
+    __Pyx_INCREF(Py_None);
     __pyx_1 = Py_None;
-    Py_INCREF(__pyx_1);
   }
   __pyx_r = __pyx_1;
   __pyx_1 = 0;
   goto __pyx_L0;
 
-  __pyx_r = Py_None; Py_INCREF(Py_None);
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
   __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_FinishRefcountContext();
   return __pyx_r;
 }
 
-/* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":118
+/* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":77
  *             return self.cleft if self.cleft is not EmptyNode else None
  *     property right_node:
  *         def __get__(self):             # <<<<<<<<<<<<<<
 
 static PyObject *__pyx_pf_2bx_9intervals_12intersection_12IntervalNode_10right_node___get__(PyObject *__pyx_v_self); /*proto*/
 static PyObject *__pyx_pf_2bx_9intervals_12intersection_12IntervalNode_10right_node___get__(PyObject *__pyx_v_self) {
-  PyObject *__pyx_r;
+  PyObject *__pyx_r = NULL;
   PyObject *__pyx_1 = 0;
-  int __pyx_2;
-
-  /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":119
+  int __pyx_t_1;
+  __Pyx_SetupRefcountContext("__get__");
+
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":78
  *     property right_node:
  *         def __get__(self):
  *             return self.cright if self.cright is not EmptyNode else None             # <<<<<<<<<<<<<<
  *     property root_node:
  *         def __get__(self):
  */
-  __pyx_2 = (((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self)->cright != __pyx_v_2bx_9intervals_12intersection_EmptyNode);
-  if (__pyx_2) {
-    __pyx_1 = ((PyObject *)((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self)->cright);
-    Py_INCREF(__pyx_1);
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = (((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self)->cright != __pyx_v_2bx_9intervals_12intersection_EmptyNode);
+  if (__pyx_t_1) {
+    __Pyx_INCREF(((PyObject *)((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self)->cright));
+    __pyx_1 = ((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self)->cright;
   } else {
+    __Pyx_INCREF(Py_None);
     __pyx_1 = Py_None;
-    Py_INCREF(__pyx_1);
   }
   __pyx_r = __pyx_1;
   __pyx_1 = 0;
   goto __pyx_L0;
 
-  __pyx_r = Py_None; Py_INCREF(Py_None);
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
   __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_FinishRefcountContext();
   return __pyx_r;
 }
 
-/* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":121
+/* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":80
  *             return self.cright if self.cright is not EmptyNode else None
  *     property root_node:
  *         def __get__(self):             # <<<<<<<<<<<<<<
 
 static PyObject *__pyx_pf_2bx_9intervals_12intersection_12IntervalNode_9root_node___get__(PyObject *__pyx_v_self); /*proto*/
 static PyObject *__pyx_pf_2bx_9intervals_12intersection_12IntervalNode_9root_node___get__(PyObject *__pyx_v_self) {
-  PyObject *__pyx_r;
+  PyObject *__pyx_r = NULL;
   PyObject *__pyx_1 = 0;
-  int __pyx_2;
-
-  /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":122
+  int __pyx_t_1;
+  __Pyx_SetupRefcountContext("__get__");
+
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":81
  *     property root_node:
  *         def __get__(self):
  *             return self.croot if self.croot is not EmptyNode else None             # <<<<<<<<<<<<<<
  * 
  *     def __repr__(self):
  */
-  __pyx_2 = (((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self)->croot != __pyx_v_2bx_9intervals_12intersection_EmptyNode);
-  if (__pyx_2) {
-    __pyx_1 = ((PyObject *)((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self)->croot);
-    Py_INCREF(__pyx_1);
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = (((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self)->croot != __pyx_v_2bx_9intervals_12intersection_EmptyNode);
+  if (__pyx_t_1) {
+    __Pyx_INCREF(((PyObject *)((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self)->croot));
+    __pyx_1 = ((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self)->croot;
   } else {
+    __Pyx_INCREF(Py_None);
     __pyx_1 = Py_None;
-    Py_INCREF(__pyx_1);
   }
   __pyx_r = __pyx_1;
   __pyx_1 = 0;
   goto __pyx_L0;
 
-  __pyx_r = Py_None; Py_INCREF(Py_None);
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
   __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_FinishRefcountContext();
   return __pyx_r;
 }
 
-/* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":124
+/* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":83
  *             return self.croot if self.croot is not EmptyNode else None
  * 
  *     def __repr__(self):             # <<<<<<<<<<<<<<
 
 static PyObject *__pyx_pf_2bx_9intervals_12intersection_12IntervalNode___repr__(PyObject *__pyx_v_self); /*proto*/
 static PyObject *__pyx_pf_2bx_9intervals_12intersection_12IntervalNode___repr__(PyObject *__pyx_v_self) {
-  PyObject *__pyx_r;
-  PyObject *__pyx_1 = 0;
-  PyObject *__pyx_2 = 0;
-  PyObject *__pyx_3 = 0;
+  PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
-
-  /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":125
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  __Pyx_SetupRefcountContext("__repr__");
+
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":84
  * 
  *     def __repr__(self):
  *         return "IntervalNode(%i, %i)" % (self.start, self.end)             # <<<<<<<<<<<<<<
  * 
  *     def __cinit__(IntervalNode self, int start, int end, object interval):
  */
-  __pyx_1 = PyInt_FromLong(((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self)->start); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_2 = PyInt_FromLong(((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self)->end); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_3 = PyTuple_New(2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);
-  PyTuple_SET_ITEM(__pyx_3, 1, __pyx_2);
-  __pyx_1 = 0;
-  __pyx_2 = 0;
-  __pyx_t_1 = PyNumber_Remainder(__pyx_kp_4, ((PyObject *)__pyx_3)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
-  __pyx_r = __pyx_t_1;
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self)->start); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyInt_FromLong(((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self)->end); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
+  __Pyx_GIVEREF(__pyx_t_1);
+  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
+  __Pyx_GIVEREF(__pyx_t_2);
   __pyx_t_1 = 0;
+  __pyx_t_2 = 0;
+  __pyx_t_2 = PyNumber_Remainder(__pyx_kp_4, ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+  __pyx_r = __pyx_t_2;
+  __pyx_t_2 = 0;
   goto __pyx_L0;
 
-  __pyx_r = Py_None; Py_INCREF(Py_None);
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
   goto __pyx_L0;
   __pyx_L1_error:;
-  Py_XDECREF(__pyx_1);
-  Py_XDECREF(__pyx_2);
-  Py_XDECREF(__pyx_3);
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
   __Pyx_AddTraceback("bx.intervals.intersection.IntervalNode.__repr__");
   __pyx_r = NULL;
   __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_FinishRefcountContext();
   return __pyx_r;
 }
 
-/* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":127
+/* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":86
  *         return "IntervalNode(%i, %i)" % (self.start, self.end)
  * 
  *     def __cinit__(IntervalNode self, int start, int end, object interval):             # <<<<<<<<<<<<<<
   PyObject *__pyx_v_interval = 0;
   int __pyx_r;
   static PyObject **__pyx_pyargnames[] = {&__pyx_kp_start,&__pyx_kp_end,&__pyx_kp_interval,0};
+  __Pyx_SetupRefcountContext("__cinit__");
   if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
     PyObject* values[3] = {0,0,0};
-    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
     switch (PyTuple_GET_SIZE(__pyx_args)) {
       case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
       case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_end);
       if (likely(values[1])) kw_args--;
       else {
-        __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
       case  2:
       values[2] = PyDict_GetItem(__pyx_kwds, __pyx_kp_interval);
       if (likely(values[2])) kw_args--;
       else {
-        __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
-    __pyx_v_start = __pyx_PyInt_int(values[0]); if (unlikely((__pyx_v_start == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
-    __pyx_v_end = __pyx_PyInt_int(values[1]); if (unlikely((__pyx_v_end == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_start = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_start == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_end = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_end == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     __pyx_v_interval = values[2];
   } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
     goto __pyx_L5_argtuple_error;
   } else {
-    __pyx_v_start = __pyx_PyInt_int(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_start == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
-    __pyx_v_end = __pyx_PyInt_int(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_end == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_start = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_start == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_end = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_end == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     __pyx_v_interval = PyTuple_GET_ITEM(__pyx_args, 2);
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("bx.intervals.intersection.IntervalNode.__cinit__");
   return -1;
   __pyx_L4_argument_unpacking_done:;
 
-  /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":132
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":91
  *         # tree size.  Also, python's uniform is perfect since the
  *         # upper limit is not inclusive, which gives us undefined here.
- *         self.priority   = ceil(nlog * log(-1.0/(1.0 * rand()/RAND_MAX - 1)))             # <<<<<<<<<<<<<<
- *         self.start      = start
- *         self.end       = end
+ *         self.priority = ceil(nlog * log(-1.0/(1.0 * rand()/RAND_MAX - 1)))             # <<<<<<<<<<<<<<
+ *         self.start    = start
+ *         self.end      = end
  */
   ((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self)->priority = ceil((__pyx_v_2bx_9intervals_12intersection_nlog * log(((-1.0) / (((1.0 * rand()) / RAND_MAX) - 1)))));
 
-  /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":133
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":92
  *         # upper limit is not inclusive, which gives us undefined here.
- *         self.priority   = ceil(nlog * log(-1.0/(1.0 * rand()/RAND_MAX - 1)))
- *         self.start      = start             # <<<<<<<<<<<<<<
- *         self.end       = end
- *         self.interval   = interval
+ *         self.priority = ceil(nlog * log(-1.0/(1.0 * rand()/RAND_MAX - 1)))
+ *         self.start    = start             # <<<<<<<<<<<<<<
+ *         self.end      = end
+ *         self.interval = interval
  */
   ((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self)->start = __pyx_v_start;
 
-  /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":134
- *         self.priority   = ceil(nlog * log(-1.0/(1.0 * rand()/RAND_MAX - 1)))
- *         self.start      = start
- *         self.end       = end             # <<<<<<<<<<<<<<
- *         self.interval   = interval
- *         self.maxend    = end
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":93
+ *         self.priority = ceil(nlog * log(-1.0/(1.0 * rand()/RAND_MAX - 1)))
+ *         self.start    = start
+ *         self.end      = end             # <<<<<<<<<<<<<<
+ *         self.interval = interval
+ *         self.maxend   = end
  */
   ((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self)->end = __pyx_v_end;
 
-  /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":135
- *         self.start      = start
- *         self.end       = end
- *         self.interval   = interval             # <<<<<<<<<<<<<<
- *         self.maxend    = end
- *         self.minstart   = start
- */
-  Py_INCREF(__pyx_v_interval);
-  Py_DECREF(((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self)->interval);
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":94
+ *         self.start    = start
+ *         self.end      = end
+ *         self.interval = interval             # <<<<<<<<<<<<<<
+ *         self.maxend   = end
+ *         self.minstart = start
+ */
+  __Pyx_INCREF(__pyx_v_interval);
+  __Pyx_GIVEREF(__pyx_v_interval);
+  __Pyx_GOTREF(((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self)->interval);
+  __Pyx_DECREF(((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self)->interval);
   ((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self)->interval = __pyx_v_interval;
 
-  /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":136
- *         self.end       = end
- *         self.interval   = interval
- *         self.maxend    = end             # <<<<<<<<<<<<<<
- *         self.minstart   = start
- *         self.minend    = end
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":95
+ *         self.end      = end
+ *         self.interval = interval
+ *         self.maxend   = end             # <<<<<<<<<<<<<<
+ *         self.minstart = start
+ *         self.minend   = end
  */
   ((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self)->maxend = __pyx_v_end;
 
-  /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":137
- *         self.interval   = interval
- *         self.maxend    = end
- *         self.minstart   = start             # <<<<<<<<<<<<<<
- *         self.minend    = end
- *         self.cleft       = EmptyNode
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":96
+ *         self.interval = interval
+ *         self.maxend   = end
+ *         self.minstart = start             # <<<<<<<<<<<<<<
+ *         self.minend   = end
+ *         self.cleft    = EmptyNode
  */
   ((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self)->minstart = __pyx_v_start;
 
-  /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":138
- *         self.maxend    = end
- *         self.minstart   = start
- *         self.minend    = end             # <<<<<<<<<<<<<<
- *         self.cleft       = EmptyNode
- *         self.cright      = EmptyNode
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":97
+ *         self.maxend   = end
+ *         self.minstart = start
+ *         self.minend   = end             # <<<<<<<<<<<<<<
+ *         self.cleft    = EmptyNode
+ *         self.cright   = EmptyNode
  */
   ((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self)->minend = __pyx_v_end;
 
-  /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":139
- *         self.minstart   = start
- *         self.minend    = end
- *         self.cleft       = EmptyNode             # <<<<<<<<<<<<<<
- *         self.cright      = EmptyNode
- *         self.croot       = EmptyNode
- */
-  Py_INCREF(((PyObject *)__pyx_v_2bx_9intervals_12intersection_EmptyNode));
-  Py_DECREF(((PyObject *)((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self)->cleft));
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":98
+ *         self.minstart = start
+ *         self.minend   = end
+ *         self.cleft    = EmptyNode             # <<<<<<<<<<<<<<
+ *         self.cright   = EmptyNode
+ *         self.croot    = EmptyNode
+ */
+  __Pyx_INCREF(((PyObject *)__pyx_v_2bx_9intervals_12intersection_EmptyNode));
+  __Pyx_GIVEREF(((PyObject *)__pyx_v_2bx_9intervals_12intersection_EmptyNode));
+  __Pyx_GOTREF(((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self)->cleft);
+  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self)->cleft));
   ((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self)->cleft = __pyx_v_2bx_9intervals_12intersection_EmptyNode;
 
-  /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":140
- *         self.minend    = end
- *         self.cleft       = EmptyNode
- *         self.cright      = EmptyNode             # <<<<<<<<<<<<<<
- *         self.croot       = EmptyNode
- * 
- */
-  Py_INCREF(((PyObject *)__pyx_v_2bx_9intervals_12intersection_EmptyNode));
-  Py_DECREF(((PyObject *)((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self)->cright));
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":99
+ *         self.minend   = end
+ *         self.cleft    = EmptyNode
+ *         self.cright   = EmptyNode             # <<<<<<<<<<<<<<
+ *         self.croot    = EmptyNode
+ * 
+ */
+  __Pyx_INCREF(((PyObject *)__pyx_v_2bx_9intervals_12intersection_EmptyNode));
+  __Pyx_GIVEREF(((PyObject *)__pyx_v_2bx_9intervals_12intersection_EmptyNode));
+  __Pyx_GOTREF(((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self)->cright);
+  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self)->cright));
   ((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self)->cright = __pyx_v_2bx_9intervals_12intersection_EmptyNode;
 
-  /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":141
- *         self.cleft       = EmptyNode
- *         self.cright      = EmptyNode
- *         self.croot       = EmptyNode             # <<<<<<<<<<<<<<
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":100
+ *         self.cleft    = EmptyNode
+ *         self.cright   = EmptyNode
+ *         self.croot    = EmptyNode             # <<<<<<<<<<<<<<
  * 
  *     cpdef IntervalNode insert(IntervalNode self, int start, int end, object interval):
  */
-  Py_INCREF(((PyObject *)__pyx_v_2bx_9intervals_12intersection_EmptyNode));
-  Py_DECREF(((PyObject *)((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self)->croot));
+  __Pyx_INCREF(((PyObject *)__pyx_v_2bx_9intervals_12intersection_EmptyNode));
+  __Pyx_GIVEREF(((PyObject *)__pyx_v_2bx_9intervals_12intersection_EmptyNode));
+  __Pyx_GOTREF(((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self)->croot);
+  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self)->croot));
   ((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self)->croot = __pyx_v_2bx_9intervals_12intersection_EmptyNode;
 
   __pyx_r = 0;
+  __Pyx_FinishRefcountContext();
   return __pyx_r;
 }
 
-/* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":143
- *         self.croot       = EmptyNode
+/* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":102
+ *         self.croot    = EmptyNode
  * 
  *     cpdef IntervalNode insert(IntervalNode self, int start, int end, object interval):             # <<<<<<<<<<<<<<
- *         cdef IntervalNode croot = self
- *         # If starts are the same, decide which to add interval to based on
+ *         """
+ *         Insert a new IntervalNode into the tree of which this node is
  */
 
 static PyObject *__pyx_pf_2bx_9intervals_12intersection_12IntervalNode_insert(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
 static  struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *__pyx_f_2bx_9intervals_12intersection_12IntervalNode_insert(struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *__pyx_v_self, int __pyx_v_start, int __pyx_v_end, PyObject *__pyx_v_interval, int __pyx_skip_dispatch) {
   struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *__pyx_v_croot = 0;
   int __pyx_v_decision_endpoint;
-  struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *__pyx_r;
+  struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *__pyx_r = NULL;
   PyObject *__pyx_1 = 0;
-  PyObject *__pyx_2 = 0;
-  PyObject *__pyx_3 = 0;
-  PyObject *__pyx_4 = 0;
-  int __pyx_5;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  int __pyx_t_4;
+  __Pyx_SetupRefcountContext("insert");
   /* Check if called by wrapper */
   if (unlikely(__pyx_skip_dispatch)) ;
   /* Check if overriden in Python */
   else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
-    __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_kp_insert); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    if (!(strcmp(Py_TYPE(__pyx_1)->tp_name, "builtin_function_or_method") == 0) || (PyCFunction_GET_FUNCTION(__pyx_1) != (void *)&__pyx_pf_2bx_9intervals_12intersection_12IntervalNode_insert)) {
-      __pyx_2 = PyInt_FromLong(__pyx_v_start); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __pyx_3 = PyInt_FromLong(__pyx_v_end); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __pyx_4 = PyTuple_New(3); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
-      PyTuple_SET_ITEM(__pyx_4, 1, __pyx_3);
-      Py_INCREF(__pyx_v_interval);
-      PyTuple_SET_ITEM(__pyx_4, 2, __pyx_v_interval);
-      __pyx_2 = 0;
-      __pyx_3 = 0;
-      __pyx_2 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      Py_DECREF(__pyx_1); __pyx_1 = 0;
-      Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
-      if (!(__Pyx_TypeTest(__pyx_2, __pyx_ptype_2bx_9intervals_12intersection_IntervalNode))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __pyx_r = ((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_2);
-      __pyx_2 = 0;
+    __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_kp_insert); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_1);
+    if (!PyCFunction_Check(__pyx_1) || (PyCFunction_GET_FUNCTION(__pyx_1) != (void *)&__pyx_pf_2bx_9intervals_12intersection_12IntervalNode_insert)) {
+      __Pyx_XDECREF(((PyObject *)__pyx_r));
+      __pyx_t_1 = PyInt_FromLong(__pyx_v_start); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __pyx_t_2 = PyInt_FromLong(__pyx_v_end); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
+      __Pyx_GIVEREF(__pyx_t_1);
+      PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
+      __Pyx_GIVEREF(__pyx_t_2);
+      __Pyx_INCREF(__pyx_v_interval);
+      PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_interval);
+      __Pyx_GIVEREF(__pyx_v_interval);
+      __pyx_t_1 = 0;
+      __pyx_t_2 = 0;
+      __pyx_t_2 = PyObject_Call(__pyx_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
+      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+      if (!(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_2bx_9intervals_12intersection_IntervalNode))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_r = ((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_t_2);
+      __pyx_t_2 = 0;
       goto __pyx_L0;
     }
-    Py_DECREF(__pyx_1); __pyx_1 = 0;
+    __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
   }
 
-  /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":144
- * 
- *     cpdef IntervalNode insert(IntervalNode self, int start, int end, object interval):
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":108
+ *         may or may not be this node!)
+ *         """
  *         cdef IntervalNode croot = self             # <<<<<<<<<<<<<<
  *         # If starts are the same, decide which to add interval to based on
  *         # end, thus maintaining sortedness relative to start/end
  */
-  Py_INCREF(((PyObject *)__pyx_v_self));
+  __Pyx_INCREF(((PyObject *)__pyx_v_self));
   __pyx_v_croot = __pyx_v_self;
 
-  /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":147
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":111
  *         # If starts are the same, decide which to add interval to based on
  *         # end, thus maintaining sortedness relative to start/end
  *         cdef int decision_endpoint = start             # <<<<<<<<<<<<<<
  */
   __pyx_v_decision_endpoint = __pyx_v_start;
 
-  /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":148
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":112
  *         # end, thus maintaining sortedness relative to start/end
  *         cdef int decision_endpoint = start
  *         if start == self.start:             # <<<<<<<<<<<<<<
  *             decision_endpoint = end
  * 
  */
-  __pyx_5 = (__pyx_v_start == __pyx_v_self->start);
-  if (__pyx_5) {
-
-    /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":149
+  __pyx_t_4 = (__pyx_v_start == __pyx_v_self->start);
+  if (__pyx_t_4) {
+
+    /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":113
  *         cdef int decision_endpoint = start
  *         if start == self.start:
  *             decision_endpoint = end             # <<<<<<<<<<<<<<
   }
   __pyx_L3:;
 
-  /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":151
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":115
  *             decision_endpoint = end
  * 
  *         if decision_endpoint > self.start:             # <<<<<<<<<<<<<<
  *             # insert to cright tree
  *             if self.cright is not EmptyNode:
  */
-  __pyx_5 = (__pyx_v_decision_endpoint > __pyx_v_self->start);
-  if (__pyx_5) {
-
-    /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":153
+  __pyx_t_4 = (__pyx_v_decision_endpoint > __pyx_v_self->start);
+  if (__pyx_t_4) {
+
+    /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":117
  *         if decision_endpoint > self.start:
  *             # insert to cright tree
  *             if self.cright is not EmptyNode:             # <<<<<<<<<<<<<<
  *                 self.cright = self.cright.insert( start, end, interval )
  *             else:
  */
-    __pyx_5 = (__pyx_v_self->cright != __pyx_v_2bx_9intervals_12intersection_EmptyNode);
-    if (__pyx_5) {
-
-      /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":154
+    __pyx_t_4 = (__pyx_v_self->cright != __pyx_v_2bx_9intervals_12intersection_EmptyNode);
+    if (__pyx_t_4) {
+
+      /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":118
  *             # insert to cright tree
  *             if self.cright is not EmptyNode:
  *                 self.cright = self.cright.insert( start, end, interval )             # <<<<<<<<<<<<<<
  *             else:
  *                 self.cright = IntervalNode( start, end, interval )
  */
-      __pyx_3 = ((PyObject *)((struct __pyx_vtabstruct_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self->cright->__pyx_vtab)->insert(__pyx_v_self->cright, __pyx_v_start, __pyx_v_end, __pyx_v_interval, 0)); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      Py_DECREF(((PyObject *)__pyx_v_self->cright));
-      __pyx_v_self->cright = ((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_3);
-      __pyx_3 = 0;
+      __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self->cright->__pyx_vtab)->insert(__pyx_v_self->cright, __pyx_v_start, __pyx_v_end, __pyx_v_interval, 0)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_GIVEREF(__pyx_t_2);
+      __Pyx_GOTREF(__pyx_v_self->cright);
+      __Pyx_DECREF(((PyObject *)__pyx_v_self->cright));
+      __pyx_v_self->cright = ((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_t_2);
+      __pyx_t_2 = 0;
       goto __pyx_L5;
     }
     /*else*/ {
 
-      /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":156
+      /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":120
  *                 self.cright = self.cright.insert( start, end, interval )
  *             else:
  *                 self.cright = IntervalNode( start, end, interval )             # <<<<<<<<<<<<<<
  *             # rebalance tree
  *             if self.priority < self.cright.priority:
  */
-      __pyx_1 = PyInt_FromLong(__pyx_v_start); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __pyx_4 = PyInt_FromLong(__pyx_v_end); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __pyx_2 = PyTuple_New(3); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);
-      PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);
-      Py_INCREF(__pyx_v_interval);
-      PyTuple_SET_ITEM(__pyx_2, 2, __pyx_v_interval);
-      __pyx_1 = 0;
-      __pyx_4 = 0;
-      __pyx_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_2bx_9intervals_12intersection_IntervalNode)), ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
-      if (!(__Pyx_TypeTest(__pyx_3, __pyx_ptype_2bx_9intervals_12intersection_IntervalNode))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      Py_DECREF(((PyObject *)__pyx_v_self->cright));
-      __pyx_v_self->cright = ((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_3);
-      __pyx_3 = 0;
+      __pyx_t_2 = PyInt_FromLong(__pyx_v_start); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __pyx_t_3 = PyInt_FromLong(__pyx_v_end); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
+      __Pyx_GIVEREF(__pyx_t_2);
+      PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3);
+      __Pyx_GIVEREF(__pyx_t_3);
+      __Pyx_INCREF(__pyx_v_interval);
+      PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_interval);
+      __Pyx_GIVEREF(__pyx_v_interval);
+      __pyx_t_2 = 0;
+      __pyx_t_3 = 0;
+      __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_2bx_9intervals_12intersection_IntervalNode)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+      if (!(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_2bx_9intervals_12intersection_IntervalNode))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GIVEREF(__pyx_t_3);
+      __Pyx_GOTREF(__pyx_v_self->cright);
+      __Pyx_DECREF(((PyObject *)__pyx_v_self->cright));
+      __pyx_v_self->cright = ((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_t_3);
+      __pyx_t_3 = 0;
     }
     __pyx_L5:;
 
-    /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":158
+    /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":122
  *                 self.cright = IntervalNode( start, end, interval )
  *             # rebalance tree
  *             if self.priority < self.cright.priority:             # <<<<<<<<<<<<<<
  *                 croot = self.rotate_left()
  *         else:
  */
-    __pyx_5 = (__pyx_v_self->priority < __pyx_v_self->cright->priority);
-    if (__pyx_5) {
-
-      /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":159
+    __pyx_t_4 = (__pyx_v_self->priority < __pyx_v_self->cright->priority);
+    if (__pyx_t_4) {
+
+      /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":123
  *             # rebalance tree
  *             if self.priority < self.cright.priority:
  *                 croot = self.rotate_left()             # <<<<<<<<<<<<<<
  *         else:
  *             # insert to cleft tree
  */
-      __pyx_1 = ((PyObject *)((struct __pyx_vtabstruct_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self->__pyx_vtab)->rotate_left(__pyx_v_self)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      Py_DECREF(((PyObject *)__pyx_v_croot));
-      __pyx_v_croot = ((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_1);
-      __pyx_1 = 0;
+      __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self->__pyx_vtab)->rotate_left(__pyx_v_self)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(((PyObject *)__pyx_v_croot));
+      __pyx_v_croot = ((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_t_3);
+      __pyx_t_3 = 0;
       goto __pyx_L6;
     }
     __pyx_L6:;
   }
   /*else*/ {
 
-    /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":162
+    /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":126
  *         else:
  *             # insert to cleft tree
  *             if self.cleft is not EmptyNode:             # <<<<<<<<<<<<<<
  *                 self.cleft = self.cleft.insert( start, end, interval)
  *             else:
  */
-    __pyx_5 = (__pyx_v_self->cleft != __pyx_v_2bx_9intervals_12intersection_EmptyNode);
-    if (__pyx_5) {
-
-      /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":163
+    __pyx_t_4 = (__pyx_v_self->cleft != __pyx_v_2bx_9intervals_12intersection_EmptyNode);
+    if (__pyx_t_4) {
+
+      /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":127
  *             # insert to cleft tree
  *             if self.cleft is not EmptyNode:
  *                 self.cleft = self.cleft.insert( start, end, interval)             # <<<<<<<<<<<<<<
  *             else:
  *                 self.cleft = IntervalNode( start, end, interval)
  */
-      __pyx_4 = ((PyObject *)((struct __pyx_vtabstruct_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self->cleft->__pyx_vtab)->insert(__pyx_v_self->cleft, __pyx_v_start, __pyx_v_end, __pyx_v_interval, 0)); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      Py_DECREF(((PyObject *)__pyx_v_self->cleft));
-      __pyx_v_self->cleft = ((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_4);
-      __pyx_4 = 0;
+      __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self->cleft->__pyx_vtab)->insert(__pyx_v_self->cleft, __pyx_v_start, __pyx_v_end, __pyx_v_interval, 0)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_GIVEREF(__pyx_t_3);
+      __Pyx_GOTREF(__pyx_v_self->cleft);
+      __Pyx_DECREF(((PyObject *)__pyx_v_self->cleft));
+      __pyx_v_self->cleft = ((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_t_3);
+      __pyx_t_3 = 0;
       goto __pyx_L7;
     }
     /*else*/ {
 
-      /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":165
+      /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":129
  *                 self.cleft = self.cleft.insert( start, end, interval)
  *             else:
  *                 self.cleft = IntervalNode( start, end, interval)             # <<<<<<<<<<<<<<
  *             # rebalance tree
  *             if self.priority < self.cleft.priority:
  */
-      __pyx_2 = PyInt_FromLong(__pyx_v_start); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __pyx_3 = PyInt_FromLong(__pyx_v_end); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __pyx_1 = PyTuple_New(3); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      PyTuple_SET_ITEM(__pyx_1, 0, __pyx_2);
-      PyTuple_SET_ITEM(__pyx_1, 1, __pyx_3);
-      Py_INCREF(__pyx_v_interval);
-      PyTuple_SET_ITEM(__pyx_1, 2, __pyx_v_interval);
-      __pyx_2 = 0;
-      __pyx_3 = 0;
-      __pyx_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_2bx_9intervals_12intersection_IntervalNode)), ((PyObject *)__pyx_1), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
-      if (!(__Pyx_TypeTest(__pyx_4, __pyx_ptype_2bx_9intervals_12intersection_IntervalNode))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      Py_DECREF(((PyObject *)__pyx_v_self->cleft));
-      __pyx_v_self->cleft = ((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_4);
-      __pyx_4 = 0;
+      __pyx_t_3 = PyInt_FromLong(__pyx_v_start); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __pyx_t_1 = PyInt_FromLong(__pyx_v_end); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
+      __Pyx_GIVEREF(__pyx_t_3);
+      PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
+      __Pyx_GIVEREF(__pyx_t_1);
+      __Pyx_INCREF(__pyx_v_interval);
+      PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_interval);
+      __Pyx_GIVEREF(__pyx_v_interval);
+      __pyx_t_3 = 0;
+      __pyx_t_1 = 0;
+      __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_2bx_9intervals_12intersection_IntervalNode)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+      if (!(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_2bx_9intervals_12intersection_IntervalNode))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GIVEREF(__pyx_t_1);
+      __Pyx_GOTREF(__pyx_v_self->cleft);
+      __Pyx_DECREF(((PyObject *)__pyx_v_self->cleft));
+      __pyx_v_self->cleft = ((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_t_1);
+      __pyx_t_1 = 0;
     }
     __pyx_L7:;
 
-    /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":167
+    /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":131
  *                 self.cleft = IntervalNode( start, end, interval)
  *             # rebalance tree
  *             if self.priority < self.cleft.priority:             # <<<<<<<<<<<<<<
  *                 croot = self.rotate_right()
  * 
  */
-    __pyx_5 = (__pyx_v_self->priority < __pyx_v_self->cleft->priority);
-    if (__pyx_5) {
-
-      /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":168
+    __pyx_t_4 = (__pyx_v_self->priority < __pyx_v_self->cleft->priority);
+    if (__pyx_t_4) {
+
+      /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":132
  *             # rebalance tree
  *             if self.priority < self.cleft.priority:
  *                 croot = self.rotate_right()             # <<<<<<<<<<<<<<
  * 
  *         croot.set_ends()
  */
-      __pyx_2 = ((PyObject *)((struct __pyx_vtabstruct_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self->__pyx_vtab)->rotate_right(__pyx_v_self)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      Py_DECREF(((PyObject *)__pyx_v_croot));
-      __pyx_v_croot = ((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_2);
-      __pyx_2 = 0;
+      __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self->__pyx_vtab)->rotate_right(__pyx_v_self)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(((PyObject *)__pyx_v_croot));
+      __pyx_v_croot = ((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_t_1);
+      __pyx_t_1 = 0;
       goto __pyx_L8;
     }
     __pyx_L8:;
   }
   __pyx_L4:;
 
-  /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":170
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":134
  *                 croot = self.rotate_right()
  * 
  *         croot.set_ends()             # <<<<<<<<<<<<<<
  */
   ((struct __pyx_vtabstruct_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_croot->__pyx_vtab)->set_ends(__pyx_v_croot);
 
-  /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":171
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":135
  * 
  *         croot.set_ends()
  *         self.cleft.croot  = croot             # <<<<<<<<<<<<<<
  *         self.cright.croot = croot
  *         return croot
  */
-  Py_INCREF(((PyObject *)__pyx_v_croot));
-  Py_DECREF(((PyObject *)__pyx_v_self->cleft->croot));
+  __Pyx_INCREF(((PyObject *)__pyx_v_croot));
+  __Pyx_GIVEREF(((PyObject *)__pyx_v_croot));
+  __Pyx_GOTREF(__pyx_v_self->cleft->croot);
+  __Pyx_DECREF(((PyObject *)__pyx_v_self->cleft->croot));
   __pyx_v_self->cleft->croot = __pyx_v_croot;
 
-  /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":172
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":136
  *         croot.set_ends()
  *         self.cleft.croot  = croot
  *         self.cright.croot = croot             # <<<<<<<<<<<<<<
  *         return croot
  * 
  */
-  Py_INCREF(((PyObject *)__pyx_v_croot));
-  Py_DECREF(((PyObject *)__pyx_v_self->cright->croot));
+  __Pyx_INCREF(((PyObject *)__pyx_v_croot));
+  __Pyx_GIVEREF(((PyObject *)__pyx_v_croot));
+  __Pyx_GOTREF(__pyx_v_self->cright->croot);
+  __Pyx_DECREF(((PyObject *)__pyx_v_self->cright->croot));
   __pyx_v_self->cright->croot = __pyx_v_croot;
 
-  /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":173
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":137
  *         self.cleft.croot  = croot
  *         self.cright.croot = croot
  *         return croot             # <<<<<<<<<<<<<<
  * 
  *     cdef IntervalNode rotate_right(IntervalNode self):
  */
-  Py_INCREF(((PyObject *)__pyx_v_croot));
+  __Pyx_XDECREF(((PyObject *)__pyx_r));
+  __Pyx_INCREF(((PyObject *)__pyx_v_croot));
   __pyx_r = __pyx_v_croot;
   goto __pyx_L0;
 
-  __pyx_r = ((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)Py_None); Py_INCREF(Py_None);
+  __pyx_r = ((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)Py_None); __Pyx_INCREF(Py_None);
   goto __pyx_L0;
   __pyx_L1_error:;
-  Py_XDECREF(__pyx_1);
-  Py_XDECREF(__pyx_2);
-  Py_XDECREF(__pyx_3);
-  Py_XDECREF(__pyx_4);
+  __Pyx_XDECREF(__pyx_1);
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
   __Pyx_AddTraceback("bx.intervals.intersection.IntervalNode.insert");
   __pyx_r = 0;
   __pyx_L0:;
-  Py_XDECREF(__pyx_v_croot);
+  __Pyx_XDECREF((PyObject *)__pyx_v_croot);
+  __Pyx_XGIVEREF((PyObject *)__pyx_r);
+  __Pyx_FinishRefcountContext();
   return __pyx_r;
 }
 
-/* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":143
- *         self.croot       = EmptyNode
+/* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":102
+ *         self.croot    = EmptyNode
  * 
  *     cpdef IntervalNode insert(IntervalNode self, int start, int end, object interval):             # <<<<<<<<<<<<<<
- *         cdef IntervalNode croot = self
- *         # If starts are the same, decide which to add interval to based on
+ *         """
+ *         Insert a new IntervalNode into the tree of which this node is
  */
 
 static PyObject *__pyx_pf_2bx_9intervals_12intersection_12IntervalNode_insert(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static char __pyx_doc_2bx_9intervals_12intersection_12IntervalNode_insert[] = "\n        Insert a new IntervalNode into the tree of which this node is\n        currently the root. The return value is the new root of the tree (which\n        may or may not be this node!)\n        ";
 static PyObject *__pyx_pf_2bx_9intervals_12intersection_12IntervalNode_insert(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
   int __pyx_v_start;
   int __pyx_v_end;
   PyObject *__pyx_v_interval = 0;
-  PyObject *__pyx_r;
-  PyObject *__pyx_1 = 0;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
   static PyObject **__pyx_pyargnames[] = {&__pyx_kp_start,&__pyx_kp_end,&__pyx_kp_interval,0};
+  __Pyx_SetupRefcountContext("insert");
   if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
     PyObject* values[3] = {0,0,0};
-    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
     switch (PyTuple_GET_SIZE(__pyx_args)) {
       case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
       case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_end);
       if (likely(values[1])) kw_args--;
       else {
-        __Pyx_RaiseArgtupleInvalid("insert", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        __Pyx_RaiseArgtupleInvalid("insert", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
       case  2:
       values[2] = PyDict_GetItem(__pyx_kwds, __pyx_kp_interval);
       if (likely(values[2])) kw_args--;
       else {
-        __Pyx_RaiseArgtupleInvalid("insert", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        __Pyx_RaiseArgtupleInvalid("insert", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "insert") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "insert") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
-    __pyx_v_start = __pyx_PyInt_int(values[0]); if (unlikely((__pyx_v_start == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
-    __pyx_v_end = __pyx_PyInt_int(values[1]); if (unlikely((__pyx_v_end == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_start = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_start == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_end = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_end == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     __pyx_v_interval = values[2];
   } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
     goto __pyx_L5_argtuple_error;
   } else {
-    __pyx_v_start = __pyx_PyInt_int(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_start == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
-    __pyx_v_end = __pyx_PyInt_int(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_end == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_start = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_start == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_end = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_end == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     __pyx_v_interval = PyTuple_GET_ITEM(__pyx_args, 2);
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("insert", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("insert", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("bx.intervals.intersection.IntervalNode.insert");
   return NULL;
   __pyx_L4_argument_unpacking_done:;
-  __pyx_1 = ((PyObject *)((struct __pyx_vtabstruct_2bx_9intervals_12intersection_IntervalNode *)((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self)->__pyx_vtab)->insert(((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self), __pyx_v_start, __pyx_v_end, __pyx_v_interval, 1)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_r = __pyx_1;
-  __pyx_1 = 0;
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_2bx_9intervals_12intersection_IntervalNode *)((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self)->__pyx_vtab)->insert(((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self), __pyx_v_start, __pyx_v_end, __pyx_v_interval, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
   goto __pyx_L0;
 
-  __pyx_r = Py_None; Py_INCREF(Py_None);
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
   goto __pyx_L0;
   __pyx_L1_error:;
-  Py_XDECREF(__pyx_1);
+  __Pyx_XDECREF(__pyx_t_1);
   __Pyx_AddTraceback("bx.intervals.intersection.IntervalNode.insert");
   __pyx_r = NULL;
   __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_FinishRefcountContext();
   return __pyx_r;
 }
 
-/* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":175
+/* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":139
  *         return croot
  * 
  *     cdef IntervalNode rotate_right(IntervalNode self):             # <<<<<<<<<<<<<<
 
 static  struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *__pyx_f_2bx_9intervals_12intersection_12IntervalNode_rotate_right(struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *__pyx_v_self) {
   struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *__pyx_v_croot = 0;
-  struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *__pyx_r;
-
-  /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":176
+  struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *__pyx_r = NULL;
+  __Pyx_SetupRefcountContext("rotate_right");
+
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":140
  * 
  *     cdef IntervalNode rotate_right(IntervalNode self):
  *         cdef IntervalNode croot = self.cleft             # <<<<<<<<<<<<<<
  *         self.cleft  = self.cleft.cright
  *         croot.cright = self
  */
-  Py_INCREF(((PyObject *)__pyx_v_self->cleft));
+  __Pyx_INCREF(((PyObject *)__pyx_v_self->cleft));
   __pyx_v_croot = __pyx_v_self->cleft;
 
-  /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":177
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":141
  *     cdef IntervalNode rotate_right(IntervalNode self):
  *         cdef IntervalNode croot = self.cleft
  *         self.cleft  = self.cleft.cright             # <<<<<<<<<<<<<<
  *         croot.cright = self
  *         self.set_ends()
  */
-  Py_INCREF(((PyObject *)__pyx_v_self->cleft->cright));
-  Py_DECREF(((PyObject *)__pyx_v_self->cleft));
+  __Pyx_INCREF(((PyObject *)__pyx_v_self->cleft->cright));
+  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->cleft->cright));
+  __Pyx_GOTREF(__pyx_v_self->cleft);
+  __Pyx_DECREF(((PyObject *)__pyx_v_self->cleft));
   __pyx_v_self->cleft = __pyx_v_self->cleft->cright;
 
-  /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":178
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":142
  *         cdef IntervalNode croot = self.cleft
  *         self.cleft  = self.cleft.cright
  *         croot.cright = self             # <<<<<<<<<<<<<<
  *         self.set_ends()
  *         return croot
  */
-  Py_INCREF(((PyObject *)__pyx_v_self));
-  Py_DECREF(((PyObject *)__pyx_v_croot->cright));
+  __Pyx_INCREF(((PyObject *)__pyx_v_self));
+  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
+  __Pyx_GOTREF(__pyx_v_croot->cright);
+  __Pyx_DECREF(((PyObject *)__pyx_v_croot->cright));
   __pyx_v_croot->cright = __pyx_v_self;
 
-  /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":179
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":143
  *         self.cleft  = self.cleft.cright
  *         croot.cright = self
  *         self.set_ends()             # <<<<<<<<<<<<<<
  */
   ((struct __pyx_vtabstruct_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self->__pyx_vtab)->set_ends(__pyx_v_self);
 
-  /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":180
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":144
  *         croot.cright = self
  *         self.set_ends()
  *         return croot             # <<<<<<<<<<<<<<
  * 
  *     cdef IntervalNode rotate_left(IntervalNode self):
  */
-  Py_INCREF(((PyObject *)__pyx_v_croot));
+  __Pyx_XDECREF(((PyObject *)__pyx_r));
+  __Pyx_INCREF(((PyObject *)__pyx_v_croot));
   __pyx_r = __pyx_v_croot;
   goto __pyx_L0;
 
-  __pyx_r = ((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)Py_None); Py_INCREF(Py_None);
+  __pyx_r = ((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)Py_None); __Pyx_INCREF(Py_None);
   __pyx_L0:;
-  Py_XDECREF(__pyx_v_croot);
+  __Pyx_XDECREF((PyObject *)__pyx_v_croot);
+  __Pyx_XGIVEREF((PyObject *)__pyx_r);
+  __Pyx_FinishRefcountContext();
   return __pyx_r;
 }
 
-/* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":182
+/* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":146
  *         return croot
  * 
  *     cdef IntervalNode rotate_left(IntervalNode self):             # <<<<<<<<<<<<<<
 
 static  struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *__pyx_f_2bx_9intervals_12intersection_12IntervalNode_rotate_left(struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *__pyx_v_self) {
   struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *__pyx_v_croot = 0;
-  struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *__pyx_r;
-
-  /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":183
+  struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *__pyx_r = NULL;
+  __Pyx_SetupRefcountContext("rotate_left");
+
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":147
  * 
  *     cdef IntervalNode rotate_left(IntervalNode self):
  *         cdef IntervalNode croot = self.cright             # <<<<<<<<<<<<<<
  *         self.cright = self.cright.cleft
  *         croot.cleft  = self
  */
-  Py_INCREF(((PyObject *)__pyx_v_self->cright));
+  __Pyx_INCREF(((PyObject *)__pyx_v_self->cright));
   __pyx_v_croot = __pyx_v_self->cright;
 
-  /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":184
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":148
  *     cdef IntervalNode rotate_left(IntervalNode self):
  *         cdef IntervalNode croot = self.cright
  *         self.cright = self.cright.cleft             # <<<<<<<<<<<<<<
  *         croot.cleft  = self
  *         self.set_ends()
  */
-  Py_INCREF(((PyObject *)__pyx_v_self->cright->cleft));
-  Py_DECREF(((PyObject *)__pyx_v_self->cright));
+  __Pyx_INCREF(((PyObject *)__pyx_v_self->cright->cleft));
+  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->cright->cleft));
+  __Pyx_GOTREF(__pyx_v_self->cright);
+  __Pyx_DECREF(((PyObject *)__pyx_v_self->cright));
   __pyx_v_self->cright = __pyx_v_self->cright->cleft;
 
-  /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":185
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":149
  *         cdef IntervalNode croot = self.cright
  *         self.cright = self.cright.cleft
  *         croot.cleft  = self             # <<<<<<<<<<<<<<
  *         self.set_ends()
  *         return croot
  */
-  Py_INCREF(((PyObject *)__pyx_v_self));
-  Py_DECREF(((PyObject *)__pyx_v_croot->cleft));
+  __Pyx_INCREF(((PyObject *)__pyx_v_self));
+  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
+  __Pyx_GOTREF(__pyx_v_croot->cleft);
+  __Pyx_DECREF(((PyObject *)__pyx_v_croot->cleft));
   __pyx_v_croot->cleft = __pyx_v_self;
 
-  /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":186
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":150
  *         self.cright = self.cright.cleft
  *         croot.cleft  = self
  *         self.set_ends()             # <<<<<<<<<<<<<<
  */
   ((struct __pyx_vtabstruct_2bx_9intervals_12intersection_IntervalNode *)__pyx_v_self->__pyx_vtab)->set_ends(__pyx_v_self);
 
-  /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":187
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":151
  *         croot.cleft  = self
  *         self.set_ends()
  *         return croot             # <<<<<<<<<<<<<<
  * 
  *     cdef inline void set_ends(IntervalNode self):
  */
-  Py_INCREF(((PyObject *)__pyx_v_croot));
+  __Pyx_XDECREF(((PyObject *)__pyx_r));
+  __Pyx_INCREF(((PyObject *)__pyx_v_croot));
   __pyx_r = __pyx_v_croot;
   goto __pyx_L0;
 
-  __pyx_r = ((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)Py_None); Py_INCREF(Py_None);
+  __pyx_r = ((struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *)Py_None); __Pyx_INCREF(Py_None);
   __pyx_L0:;
-  Py_XDECREF(__pyx_v_croot);
+  __Pyx_XDECREF((PyObject *)__pyx_v_croot);
+  __Pyx_XGIVEREF((PyObject *)__pyx_r);
+  __Pyx_FinishRefcountContext();
   return __pyx_r;
 }
 
-/* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":189
+/* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":153
  *         return croot
  * 
  *     cdef inline void set_ends(IntervalNode self):             # <<<<<<<<<<<<<<
  */
 
 static INLINE void __pyx_f_2bx_9intervals_12intersection_12IntervalNode_set_ends(struct __pyx_obj_2bx_9intervals_12intersection_IntervalNode *__pyx_v_self) {
-  int __pyx_1;
-
-  /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":190
+  int __pyx_t_1;
+  int __pyx_t_2;
+  int __pyx_t_3;
+  __Pyx_SetupRefcountContext("set_ends");
+
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":154
  * 
  *     cdef inline void set_ends(IntervalNode self):
  *         if self.cright is not EmptyNode and self.cleft is not EmptyNode:             # <<<<<<<<<<<<<<
  *             self.maxend = imax3(self.end, self.cright.maxend, self.cleft.maxend)
  *             self.minend = imin3(self.end, self.cright.minend, self.cleft.minend)
  */
-  __pyx_1 = (__pyx_v_self->cright != __pyx_v_2bx_9intervals_12intersection_EmptyNode);
-  if (__pyx_1) {
-    __pyx_1 = (__pyx_v_self->cleft != __pyx_v_2bx_9intervals_12intersection_EmptyNode);
+  __pyx_t_1 = (__pyx_v_self->cright != __pyx_v_2bx_9intervals_12intersection_EmptyNode);
+  if (__pyx_t_1) {
+    __pyx_t_2 = (__pyx_v_self->cleft != __pyx_v_2bx_9intervals_12intersection_EmptyNode);
+    __pyx_t_3 = __pyx_t_2;
+  } else {
+    __pyx_t_3 = __pyx_t_1;
   }
-  if (__pyx_1) {
-
-    /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":191
+  if (__pyx_t_3) {
+
+    /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":155
  *     cdef inline void set_ends(IntervalNode self):
  *         if self.cright is not EmptyNode and self.cleft is not EmptyNode:
  *             self.maxend = imax3(self.end, self.cright.maxend, self.cleft.maxend)             # <<<<<<<<<<<<<<
  */
     __pyx_v_self->maxend = __pyx_f_2bx_9intervals_12intersection_imax3(__pyx_v_self->end, __pyx_v_self->cright->maxend, __pyx_v_self->cleft->maxend);
 
-    /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":192
+    /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":156
  *         if self.cright is not EmptyNode and self.cleft is not EmptyNode:
  *             self.maxend = imax3(self.end, self.cright.maxend, self.cleft.maxend)
  *             self.minend = imin3(self.end, self.cright.minend, self.cleft.minend)             # <<<<<<<<<<<<<<
  */
     __pyx_v_self->minend = __pyx_f_2bx_9intervals_12intersection_imin3(__pyx_v_self->end, __pyx_v_self->cright->minend, __pyx_v_self->cleft->minend);
 
-    /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":193
+    /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":157
  *             self.maxend = imax3(self.end, self.cright.maxend, self.cleft.maxend)
  *             self.minend = imin3(self.end, self.cright.minend, self.cleft.minend)
  *             self.minstart = imin3(self.start, self.cright.minstart, self.cleft.minstart)             # <<<<<<<<<<<<<<
     goto __pyx_L3;
   }
 
-  /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":194
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":158
  *             self.minend = imin3(self.end, self.cright.minend, self.cleft.minend)
  *             self.minstart = imin3(self.start, self.cright.minstart, self.cleft.minstart)
  *         elif self.cright is not EmptyNode:             # <<<<<<<<<<<<<<
  *             self.maxend = imax2(self.end, self.cright.maxend)
  *             self.minend = imin2(self.end, self.cright.minend)
  */
-  __pyx_1 = (__pyx_v_self->cright != __pyx_v_2bx_9intervals_12intersection_EmptyNode);
-  if (__pyx_1) {
-
-    /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":195
+  __pyx_t_3 = (__pyx_v_self->cright != __pyx_v_2bx_9intervals_12intersection_EmptyNode);
+  if (__pyx_t_3) {
+
+    /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":159
  *             self.minstart = imin3(self.start, self.cright.minstart, self.cleft.minstart)
  *         elif self.cright is not EmptyNode:
  *             self.maxend = imax2(self.end, self.cright.maxend)             # <<<<<<<<<<<<<<
  */
     __pyx_v_self->maxend = __pyx_f_2bx_9intervals_12intersection_imax2(__pyx_v_self->end, __pyx_v_self->cright->maxend);
 
-    /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":196
+    /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":160
  *         elif self.cright is not EmptyNode:
  *             self.maxend = imax2(self.end, self.cright.maxend)
  *             self.minend = imin2(self.end, self.cright.minend)             # <<<<<<<<<<<<<<
  */
     __pyx_v_self->minend = __pyx_f_2bx_9intervals_12intersection_imin2(__pyx_v_self->end, __pyx_v_self->cright->minend);
 
-    /* "/Users/james/projects/bx-python/code/bx-python/lib/bx/intervals/intersection.pyx":197
+    /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/intervals/intersection.pyx":161
  *             self.maxend = imax2(self.end, self.cright.maxend)
  *             self.minend = imin2(self.end, self.cright.minend)
  *             self.minstart = imin2(self.start, self.cright.minstart)             # <<<<<<<<<<<<<<
     goto __pyx_L3;
   }