WIP: large refactor of bestmove