database: Implemented compaction of database and native dict/set access