The add function tries to add an input to the current set. It therefore calculates what the new set would look like before actually adding. This commit isolates the state of the tentative set so that there is less opportunity for bugs to creep in.