Bug fix and add an undo feature.