clean up the transform code a bit