Fixed castling invalidation code