Refactor parsoid