       else if state.phase == 'treasure'
         state.phase = 'buy'
     
-    state.log("")
-    state.log("HYPOTHETICAL start. Ignore everything...")
-
     [hypothesis, hypothetically_my] = state.hypothetical(this)
+    #  We need to save draw and discard before emptying and restore them before buyPhase, to be able to choose the right buys in actionPriority(state)
+    oldDraws   = hypothetically_my.draw.slice(0)
+    oldDiscard = hypothetically_my.discard.slice(0)
     hypothetically_my.draw = []
     hypothetically_my.discard = []
     
     while hypothesis.phase != 'buy'
       hypothesis.doPlay()
-
-    state.log("HYPOTHTICAL end. ... until here!")
-    state.log("")
-    
+      
+    hypothetically_my.draw = oldDraws
+    hypothetically_my.discard = oldDiscard
+
     return hypothesis
   
   pessimisticCardsGained: (state) ->

      [hypState, hypMy] = state.hypothetical(my.ai)
      # technically, we don't want to discard but to put back, but for pessimisticBuy this should not matter
      dis = hypState.requireDiscard(hypMy, 1)
      state.log("Discarded: #{dis}")
      defaultGained = hypMy.ai.pessimisticCardsGained(hypState)
      state.log("Defaultgain: #{defaultGained}")
      
      # determine which treasures are in hand, discard them hypothetically and test if the gains change.  When it doesn't, we can put back this card.
      treasures = []

        if (card.isTreasure) and (not (card in treasures))
          treasures.push card
            
      for treasure in treasures
        [hypState, hypMy] = state.hypothetical(my.ai)
        hypMy.doDiscard(treasure)
        nowGained = hypMy.ai.pessimisticCardsGained(hypState)
        # test arrays on equality. Better way?
        # changed order in gaining messes this up. Just ignore?
        equal = true
