Add optional schematype tag for schema autodetection

* Add <schematype> tag. If set to "flat", the flat schema is used.
* fix bug where custom user-set schema was being ignored.