building and freeing minimax while pruning