[IMP] Generic rewriting