Schema validation

Add schema validation facilities and start using them instead of parser exceptions when possible.