More work on CRF implementation.

Copied over the trellis implementations from previous HMM implementation.
I will likely port that too...