Update quantity correctly on undo

Addresses the code problems for #69