Some performance optimizations, model counting bug still exists