Code rewriting