fixed validation and piddled with the tests -- I apologize, the tests are inexcusably horrible
minor cleanup
major refactoring of validation machinery, plus some minor edits