Replaced random with random generator. Fixed crashbug with unit id and with hist_event_id. Relaxed arguments to historical entity a bit.