Finally fixed the transition probability stuff and added tests.