Changes most of the logic.  This time it actually works.