Fixed some problems with the schema SQL

Some bugs slipped in during the switch to external files.