gdbm reorganization

Quite a trivial change today, we store a stat struct within each database that maintains the deletion count.
This is only updated when something is unset (i.e. deleted). Once it hits MAX_DELETIONS (50), we organise the database, and reset the deletion counter.

This will help with db overall size, consistency and prevent I/O bottlenecks for very active layers.