phash: fix resizing of hash file map
phash: improved pruning and database size control. added DB exercise code. cleanup.
libmdb: code update (fix MDB_NEXT/MDB_PREV crash on empty databases bug that I reported)