undo support for directories and improved undo error handling