When the table creation SQL is re-run when the schema contains foreign keys, you will get referential integrity complaints.
This is because the table drop order means that it tries to drop dependent tables first.
To fix this, the drop statements should be before all the creates. They should also be in reverse order to the creates.
A method to be able to obtain the tables in reverse order will be needed to allow the templates to be modified to fix this.