Use Object equality when checking if rewrites have occurred

To achieve this, the Rewriters now work with AnyRef rather than Any