Fixed several bugs in schema validation

Mostly a result of values being coerced wrongly.