Refactored alphabeta search