This round about chain of events kind of caused the current bug being fixed (in some ways), and made it really hard to construct an easy fix (hence the amount of change).  I think it's good for now, but I'll add a "refactor" issue to take another look at this whole thing.