Add more debug logging in RewriteUtil