A bit more data integrity stuff, and better error messaging