Initial complete version of Viterbi implementation.