correct forward/backward algorithm, add more comments