Fix some minor formatting and code organization issues.
Fix some issues in the new code on this branch related to the handling of corrupt databases.
Ensure that the "Any prior cache entry associated with newKey is guaranteed not to be pinned" guarantee made to xRekey implementations is not violated.