minimax, some enhancements/refactor