The global.wave_defense.gui_actions[player_index] table does not have elements removed when an upgrade is purchased. This leads to 8 extra values every time an upgrade is purchased.
It may be from these two lines being improperly ordered, line ~1196 of wave_defense.lua:
gui.clear removes the children, so only the upgrade_table is deregistered. If the lines are swapped, it ought to deregister everything, and then 'clear' the children.