Move rewriter class into its own file.

Signed-off-by: Rami Ylimäki <rami.ylimaki@vincit.fi>