better handle database opening (cleanup + unallocated blocks)