Total rewrite = vast speed improvement for legal_moves()