Rewritting the negamax algo along with some refactoring.