Belief propagation rebase

Rebased version of old BP branch. Let's see what travis thinks.