Corrected behaviour of pop_until_game_state and checked for bad argument, which would otherwise cause an infinite loop. Also allowed popping until a specific class of state.
Corrected behaviour of pop_until_game_state and checked for bad argument, which would otherwise cause an infinite loop. Also allowed popping until a specific class of state.

ndrluis/chingu,Spooner/chingu,ippa/chingu