added a bunch of stuff while trying to sort out incorportating the C code with cython. Sorry for the mess :)
Merge fixed