Chain cython

stealing @larsmans's viterbi