A little bit of refactoring.

Some functions were generalized from BayesNetwork to VariableMap.