Add undo operation. Generalize the broadcast function. Not tested yet.