Better srand initialization
(cherry picked from commit 31e22f684fc8da83320188e5cec430e4182a9b39)