Protect thread resource freeing using try..finally
Start supporting foreign keys in script database - still needs work for compound keys. Use some field names instead of field numbers for maintainability/readability