To keep track of the actions performed in each GO Factory state, each state contains a pointer to the last undo history item which was done before the state was set as the current one. In case of cleanup, the undo history items are undone up to the one that the particular state points to.
This is the reason why the GO Factory needs to have several undo history items enabled and why extremely low undo history limits cause strange behaviour – the GO Factory cannot keep track of actions performed and if you cancel the whole creation, it undoes only the existing undo items, which may not be all items used. Also, when the GO Factory is creating an object, no other editing actions are permitted; especially the actions that create their own undo history items, or undo and redo actions. The reason for that is obvious now.
It is also possible that some GO Factory states have no action functions or generate no undo history items. In that case several states may point to the same undo history item, which does not cause any problems.
When an object creation ends successfully, all new undo items are merged into one.