Rewriting tests, and some minor refactoring. Still not passing tests against previous results (not even close.)