Worked on --undo option; fixed some bugs