Merge "Fixed a leak with TransformStates" into pi-dev