Reorganize rewrite rules
Improve rewrite rules