New db format

Closes #16