Adds Undo and Redo functionality, closes #46.