Fix checksum calculation; throw if checksum fails.