catalogue: Fix and speed up undo.