Corrected checksums and made foreign key conditional