Auto-generate chapter IDs; bug fixes

We now generate the IDs for book chapters when we deserialize the book
for the first time. If any IDs are present in the XML, we ignore those.
We do not regenerate the IDs each time the blob "cache" is rebuilt (we
read from the DB during cache rebuild).

Also took this opportunity to clean up a lot of dead code and fixed
silent bugs.