Correct transform and remove unused variables