2i: Refactoring in compaction/optimize