Fixed a bug where api::random() was crashing