Clean up apply_affine_transform()