fix bugs in ExactInference