more cython stuff, gains are unfortunately minimal
some optimizations