fixed foreign key ordering issues with models