Another set of changes to minimization.
Not very sure about correctness.