Fixed castling and threefold repetition.