Ported all c++ code to Cython.