Undo works, but image skewed

The undo for the pinch and rotate works, but the images are skewed.
Undoing these actions also cause a huge offset of the object's position.