Re-implement rewrite module using rewrite_cell
Re-implement rewrite module using rewrite_cell