Untested BP code added
Move energy calculation to CRF class