all tests pass, there's still bugs... grr
refactoring some more