Fix many validation bugs and failing tests.