New random implementation to make full use of C++11.