Make flush part of compaction process

This will enable user to use only 1 background thread.