Fixed memory leak in transform