a few more changes to avoid illegal moves