More foreign key and syntax fixes