Wow this is almost working.  Gotta fix all the stupid edge cases.