some viterbi optimizations