Internal: refactored Rewriting module