First pass at a whole new DB format

Part of #16
More tests, a few fixes
Merge pull request #17 from eapache/new-db-format

New db format