Fix errors in modified sum product algorithm