Finish rewriting of schema handling; now supports nested definitions.