Fix bugs in new schema validation logic.