Further optimize the empty/remove/cleanData logic.