Cleaned up the transform and inverse transform code.