Fixed crash with foreign key.