Added some helper functions to help in-place optimization of transformations.