Close pending unclosed groups when undo'ing.
Remove debugging code.