Fix a bug in CorePrep that meant output invariants not satisfied