Moved is_move_legal to a more logical place