Improved performance by rewriting transformations and a bit of compiling